Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to get manifest file to work
Message
De
17/04/2020 06:47:44
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01674070
Message ID:
01674074
Vues:
85
This message has been marked as a message which has helped to the initial question of the thread.
J'aime (2)
>>>Hi folks,
>>>
>>>I am trying to make a manifest file work, following the steps described by Rick Strahl (https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=890)
>>>
>>>It sounds fairly simple, but for some reason it does not work. When I open the executable in ResourceHacker, I can only see the original default manifest embedded, but the custom app.exe.manifest file seems to get ignored completely. I wonder what I could be missing?
>>
>>Christian,
>>
>>I would advise you to check on two things: a) that your manifest file does not have other extension (like txt or xml); and b) it's placed in the same folder of your project (pjx) file.
>
>Also a small simple project does not work. Perhaps it has to do that I am compiling with VFP9 SP1. I will later try on SP2 on another machine.

Christian,

Here it is a self-contained test. You may try to run it. The message it should display is Assembly Identity name: vfp9.test.manifest. If not, then as you hinted your setup is not ready for manifest replacement.
* 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
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform