Hi Oleg,

You correct of course. 

But what I am showing is a trick. ;) So what I do is try to run J first and let 
it fail if J.EXE was not registered properly. I then "look" for J.exe and 
register it manually.

I normally distribute J.exe and J.dll with my .NET executable so it's fairly 
safe for me to look for it in the current directory of the the executable and 
use SHELL to force it to self register (by running j.exe /regserver). :D

r/Alex

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Oleg Kobchenko
Sent: Tuesday, July 07, 2009 3:43 PM
To: Programming forum
Subject: Re: [Jprogramming] detecting j on windows


.NET and COM find COM components through none other than
the registry. They ain't called registered for nothing.
Search regedit for JEXEServer. It's going to be the ProgID,
which will also have a CLSID, which in turn will have the
location of the EXE file in Local Server.
(Or so, I write from memory.)



> From: Alex Rufon <[email protected]>
> 
> Hi. 
> 
> If you need to detect J on windows using .NET code, I usually do it this way,
> 
> 1. Create an instance of J and try to send or execute any command there.
> 2. Enclose the code in a try ... catch and handle the error.
> 
> The following example code does exactly that. I have a wrapper class called 
> J.Session() which is a .NET wrapper to J.EXE, if any of the methods fail, it 
> would assume that J is in the current directory and try to register it. You 
> can 
> use any other method of finding out where J is though.
>         Try
>             'What we do is we try to make an instance of jSession and close 
> it 
> immediately
>             jSession = New J.Session(False)
>             'Execute a magic number
>             jSession.variable("WIFE", "Vilma")
>             jSession.eval("temp=. i. 42")
>             'If we got here, J is properly installed
>             jSession.Dispose()
>         Catch ex As Exception
>             'Were here so that means J is not properly installed
>             returnValue = False
>             If (register) Then
>                 'We start by getting the application path
>                 appPath = 
> System.Reflection.Assembly.GetExecutingAssembly.Location
>                 appPath = System.IO.Path.GetDirectoryName(appPath)
>                 'We now register the library
>                 Shell(appPath + "\j.exe /regserver", 
> AppWinStyle.NormalNoFocus, 
> True, -1)
>             End If
>         End Try
> 
> For more info on the J.NET wrapper class, go to: 
> http://www.jsoftware.com/jwiki/Guides/J%20VB.NET
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Jack Andrews
> Sent: Tuesday, July 07, 2009 9:38 AM
> To: Programming forum
> Subject: Re: [Jprogramming] detecting j on windows
> 
> >> > dir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\j*"
> >
> > I guess you already got a solution.  What's wrong with it?  Or you
> > prefer the J installer to add that to %PATH% automatically?
> 
> nothing wrong with it.  i just posted that solution for the benefit
> of future readers of this thread.
> 
> while on the topic of %PATH%, it seems the equivalent of unix's
> /usr/bin is c:\windows\system32.  i've been considering using
> the system32 dir as an install location in the way unix dumps
> binaries in /usr/bin.   no problems with %PATH% then :)
> 
> examples of exe's in system32:
>   calc.exe
>   ftp.exe
>   java.exe
>   notepad.exe
>   mspaint.exe
> 
> 
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



      
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to