* tests manifest inclusion in a VFP9 executable * when the executable runs, it searches its own file for the * the assembly name LOCAL Source AS String LOCAL Manifest AS String LOCAL SafetyStatus AS String LOCAL DefaultStatus AS String LOCAL TempDir AS String m.DefaultStatus = SET("Directory") m.SafetyStatus = SET("Safety") SET SAFETY OFF * prepare the project folder * it can be safely emptied afterwards m.TempDir = ADDBS(SYS(2023)) + "vfp9-manifest" IF !DIRECTORY(m.TempDir) MKDIR (m.TempDir) ENDIF SET DEFAULT TO (m.TempDir) * the executable program source TEXT TO m.Source NOSHOW LOCAL Myself AS String LOCAL Manifest AS String m.Myself = FILETOSTR(_VFP.ServerName) m.Manifest = STREXTRACT(m.Myself, "<?xml" + " version=", "</assembly>", 1, 4) IF !EMPTY(m.Manifest) LOCAL XML AS MSXML2.DOMDocument60 m.XML = CREATEOBJECT("MSXML2.DOMDocument.6.0") m.XML.LoadXML(m.Manifest) m.XML.Setproperty("SelectionNamespaces", "xmlns:ms='urn:schemas-microsoft-com:asm.v1'") LOCAL AssemblyName AS String m.AssemblyName = m.XML.Selectnodes("/ms:assembly/ms:assemblyIdentity/@name").item(0).text MESSAGEBOX(TEXTMERGE("Assembly Identity name: <<m.AssemblyName>>")) ELSE MESSAGEBOX("Manifest not found...") ENDIF ENDTEXT STRTOFILE(m.Source, "testexe.prg", 0) * create the manifest TEXT TO m.Manifest 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="vfp9.test.manifest" processorArchitecture="x86" /> <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 * save the manifest and put it close to the project, for linking STRTOFILE(m.Manifest, "testexe.exe.manifest", 0) * a project is built BUILD PROJECT "TestExe" FROM "testexe.prg" * and an executable, out of it BUILD EXE TestExe.exe FROM TestExe RECOMPILE * now, run the executable RUN /N TestExe.exe SET DEFAULT TO (m.DefaultStatus) IF m.SafetyStatus == "ON" SET SAFETY ON ENDIF