Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Call VFP COM component not registered but using .Manifes
Message
De
12/05/2020 07:39:51
 
 
À
10/05/2020 06:13:30
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01674338
Message ID:
01674370
Vues:
49
>Luis,
>
>This is an adaptation on a experiment I published elsewhere, but it will give a basic self-contained demo of what you need. Don't forget to run VFP as an administrator (since you're publishing and registering a COM Server).
>
>
>* NOTE: must be run as an administrator
>
>* create a VFP COM server and instantiate an object in a VFP application without registering it
>
>* the class ID is automattically fetched from the Automation Registration file (*.vbr)
>
>LOCAL Source AS String
>LOCAL Manifest AS String
>LOCAL SafetyStatus AS String
>LOCAL DefaultStatus AS String
>LOCAL TempDir AS String
>LOCAL DLLFullPath AS String
>
>m.DefaultStatus = SET("Directory")
>m.SafetyStatus = SET("Safety")
>
>SET SAFETY OFF
>
>* the folder can be safely emptied afterwards
>m.TempDir = ADDBS(SYS(2023)) + "vfp-com-manifest"
>IF !DIRECTORY(m.TempDir)
>	MKDIR (m.TempDir)
>ENDIF
>SET DEFAULT TO (m.TempDir)
>
>* the executable main (and single) program source
>TEXT TO m.Source NOSHOW
>	LOCAL Test AS TestLibHW.TestClass
>
>	m.Test = CREATEOBJECT("TestLibHW.TestClass")
>
>	MESSAGEBOX(m.Test.HelloWorld())
>ENDTEXT
>
>STRTOFILE(m.Source, "testexe.prg", 0)
>
>* the DLL class source
>TEXT TO m.Source NOSHOW
>	DEFINE CLASS TestClass AS Session OLEPUBLIC
>
>		FUNCTION HelloWorld
>
>			RETURN "Hello, World!"
>
>		ENDFUNC
>
>	ENDDEFINE
>ENDTEXT
>
>STRTOFILE(m.Source, "testlib-hw.prg", 0)
>
>* build a project for it, and then the DLL itself
>BUILD PROJECT "TestLibHW" FROM "testlib-hw.prg"
>
>m.DLLFullPath = ADDBS(m.TempDir) + "testlibhw.dll"
>
>BUILD DLL (m.DLLFullPath) FROM "TestLibHW" RECOMPILE
>
>* unregister, to make sure we don't have it available in the registry
>RUN REGSVR32 /u "&DLLFullPath."
>
>* create the manifest
>TEXT TO m.Manifest TEXTMERGE NOSHOW
><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
>	<assemblyIdentity 
>		version="1.0.0.0" 
>		type="win32" 
>		name="Testing with reg free servers" 
>		processorArchitecture="x86"
>	/>
>	<file name="testlibhw.dll">
>	  <comClass clsid="{<<STREXTRACT(FILETOSTR("testlibhw.vbr"), "\CLSID = {", "}")>>}"
>	           threadingModel="Apartment"
>	           progid="testlibhw.testclass"
>	           description="testlibhw.testclass" />
>	</file>
>	<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
>		<security>
>			<requestedPrivileges>
>				<requestedExecutionLevel level="asInvoker" /> 
>			</requestedPrivileges>
>		</security>
>	</trustInfo>
>	<dependency>
>	    <dependentAssembly>
>	        <assemblyIdentity
>	            type="win32"
>	            name="Microsoft.Windows.Common-Controls"
>	            version="6.0.0.0"
>	            language="*"
>	            processorArchitecture="x86"
>	            publicKeyToken="6595b64144ccf1df"
>	        />
>	    </dependentAssembly>
>	</dependency>
></assembly>
>ENDTEXT
>
>STRTOFILE(m.Manifest, "testexe.exe.manifest", 0)
>
>BUILD PROJECT "TestExe" FROM "testexe.prg"
>
>BUILD EXE TestExe.exe FROM TestExe RECOMPILE
>
>* run as an independent process, the SxS on the manifest will be used
>RUN TestExe.exe
>
>SET DEFAULT TO (m.DefaultStatus)
>IF m.SafetyStatus == "ON"
>	SET SAFETY ON
>ENDIF 
>
Thank you very much Antonio. Your example helped me a lot, not only to create a .manifest file for me but also, to understand how to use the .manifest file because before that, I was in the wrong way.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform