Thanks Tracy - somebody has already done the work for me
(http://www.tek-tips.com/viewthread.cfm?qid=1072829)
It was just a question of finding the right thing to search (in my case foxpro
localserver32)
Here is the code:
* CheckServer.prg
* (c) 2000, Tamar E. Granor and Della Martin
* From: Microsoft Office Automation with Visual FoxPro
* Hentzenwerke Publishing. www.hentzenwerke.com
LPARAMETER cServerName
LOCAL oRegistry, cClassID, cEXEName, lEXEExists, ;
aClassIDValues, aClassIDValues, aServerNameValues
IF VERSION() = "Visual FoxPro 06"
oRegistry = NewObject("Registry", HOME() + "FFC\Registry")
ELSE
SET PROCEDURE TO HOME() + "samples\classes\registry.prg" ADDITIVE
oRegistry = CreateObject("Registry")
ENDIF
lEXEExists = .F.
DECLARE aClassIDValues[1], aServerNameValues[1]
WITH oRegistry
* Find the CLSID of the server. First, look for
* the Class's Key.
IF .OpenKey(cServerName + "\CLSID") = 0
* The Class's Key is open, now enumerate its values
.EnumKeyValues(@aClassIDValues)
* The data portion of the first (only) value returned
* is the CLSID. Find the LocalServer32 key for the CLSID
IF .OpenKey("CLSID\" + aClassIDValues[1,2] + "\LocalServer32") = 0
* Enumerate teh LocalServer32 values
.EnumKeyValues(@aServerNameValues)
* The EXE file is stored in the first (only) data value returned.
cEXEName = aServerNameValues[2]
* The value that's returned may have " -Automation" or " /Automation" or
* " /AUTOMATION" & other trailing stuff at the end. Strip it off.
IF "AUTO" $ UPPER(cEXEName)
cEXEName = LEFT(cEXEName, ATC("AUTO", UPPER(cEXEName)) - 2)
ENDIF
* Verify that the file exists
lEXEExists = FILE(cEXEName)
ENDIF
ENDIF
ENDWITH
RETURN lEXEExists
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Tracy
Pearson
Sent: 20 July 2017 16:28
To: [email protected]
Subject: RE: Location of Out-of-process automation server
Paul,
Once you find the MyServer.MyOLEPublicClass1, you get the value from the CLSID
key.
Then you'll look for the CLSID with that value. Here you'll find what you need.
The InprocServer32 key will hold the filename, and usually the full path of the
EXE/DLL file.
HTH,
Tracy
Tracy Pearson
PowerChurch Software
Paul Newton wrote on 2017-07-20:
> Hi all
>
> Let's say that I have an out-of-process automation server
> (MyServer.EXE)
containing OLEPUBLIC classes like MyOLEPublicClass1 etc and then I use
CreateObject like this:
>
> o = CreateObject("MyServer.MyOLEPublicClass1")
>
> Class MyOLEPublicClass1 can determine the location of MyServer.EXE
> using
the _VFP.ServerName property but what I want to do is determine the location
of MyServer.EXE BEFORE I use CreateObject. I imagine this should be possible
via the registry (looking for an entry that refers to
"MyServer.MyOLEPublicClass1" but I cannot get further than that.
>
> Any ideas ? Thanks
>
> Paul Newton
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/by2pr0201mb1797044a0bd07573eec2121ca1...@by2pr0201mb1797.namprd02.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.