Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetObject once more
Message
De
28/11/2005 16:11:32
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01071961
Message ID:
01072609
Vues:
31
Hello,

i think i got it to work.

One has to create a executable that hosts the COM object, and the COM object itself has to be compiled as a Multithreaded-DLL.

e.g.
A simple hosting executable.
CD (FULLPATH(JUSTPATH(_VFP.ServerName)))
PUBLIC loServ, lnKey
loServ = .NULL.
lnKey = 0
ON KEY LABEL ALT+F4 EndServer()
ON SHUTDOWN EndServer()
SET LIBRARY TO vfp2c32.fll ADDITIVE
loServ = CREATEOBJECT('your.Object')
lnKey = RegisterObjectAsFileMoniker('loServ','your.Object','\\yourServer\yourShare\someFile')

READ EVENTS
IF lnKey != 0
	RevokeActiveObject(lnKey)
ENDIF
loServ = .NULL.
RELEASE LIBRARY 'vfp2c32.fll'

FUNCTION EndServer
	CLEAR EVENTS
	QUIT
ENDFUNC
additionally one has to add some registry keys.
(see http://support.microsoft.com/default.aspx?scid=kb;en-us;171974
for more details)

copy the following into a "yourserver.reg" file and execute it:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AppId\yourserver.exe]
"AppId"="{D18D0DD7-1861-490f-89A7-6DB05CC0B792}"
[HKEY_CLASSES_ROOT\AppId\{D18D0DD7-1861-490f-89A7-6DB05CC0B792}]
"RunAs"="Interactive User"
replace the GUID ({D18 ..}) with a new GUID created by guidgen.exe (located in Visual Studio\Common\Tools directory).
replace "yourserver.exe" with the name of your hosting executable.

for development this should be sufficient, but running your DCOM object in a production environment as "Interactive User" isn't adviseable, it's better when you run your hosting executable as a Windows service
(see http://blogs.msdn.com/calvin_hsia/search.aspx?q=service&p=1 ).
Then you'll also have to change the registry keys (see the KB article), i can't test this since the "Windows Resource Kit 2003" refuses to install on my Win2K machine.

Regards
Christian
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform