views:

853

answers:

3

My last question "List service and services status under Win-7" made me start working on a solution that gives my app the admin privileges under Windows Vista onward based on a .manifest file.

I was not sure about continue the previous question with this matter since they are not the same so here is another question:

My app now works fine under Win 7 whether or not I run it "as admin" because of the manifest file. My manifest file is as follow:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.6.0.5" processorArchitecture="X86" name="ServiceMonitorPro" type="win32"/>
  <description publisher="Powershield Ltd" product="Powershield Service Monitor">Powershield Service Monitor</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
   <security>
    <requestedPrivileges>
     <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
    </requestedPrivileges>
   </security>
  </trustInfo>
 </assembly>

When the application runs on windows 7 or Vista, the UAC comes with a dialog like this: alt text

How can I replace the "unknow" publisher?

The other and bigest problem is, even thou the app runs with no problem under Win7 or Vista, under WinXP it is now crashing with the message: "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."

Another thing I would like to add: If I add reference (uses clause) to XPMan the app works fine on WinXP but then it my .manifest file makes no diference under Vista or Win7.

+7  A: 

You need to sign your code with a code signing certificate. There should be lots of examples here. I have re-tagged your question with "code-signing", and you can also look for "certificate".
I use Comodo certs myself, and sign them with the awesome, wonderful, Visual Build Pro v6, which is an advertiser here on SO.

Chris Thornton
Hi, ok - will check this, thanks - any ideas with the other problem?
Ronaldo Junior
Sorry, haven't seen that other one.
Chris Thornton
@Ronaldo: The other error message has to do with the so-called "side-by-side configuration". In simple terms, it's expecting to find some run-time library, but can't. It's seen relatively often for VC++ applications built with recent compilers. That wouldn't normally be a problem for Delphi apps, though. Are you depending on some external DLLs? Have you checked that they're actually available on XP, or if they need to be installed seperately? If they need to be installed, did you actually remember to install them? (Hey, you never know...)
Michael Madsen
Hi Michael, thanks for the comment - Its a really simple app - it does not depend on external DLLs.I'm still hunting some solution for this one...
Ronaldo Junior
@Ronaldo - then perhaps your XML is making Windows "think" that there's supposed to be a DLL? I don't know, just a hunch. I don't know how to read that stuff in there...
Chris Thornton
Thanks Chris - your comment made me dig a little bit and find the "solution"...
Ronaldo Junior
+5  A: 

I have to thank everyone that, with comments or answers point me to keep digging... :) I went to search for the file WindowsXP.res. The content of that file is:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    type="win32"
    name="DelphiApplication"
    version="1.0.0.0" 
    processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
</assembly>

The solution: I have mixed my .manifest file with the WindowsXP.Res xml one adding the dependency section. If anyone know why its now working, I would be glad to hear about - but this was the solution here - tested so far in a couple of virtual machines, on my computer and a couple of others... working :)

Ronaldo Junior
Awesome! Thanks for posting the solution back here. I think there's a nice badge for that, if it gets upvoted enough.
Chris Thornton
+2  A: 

You can indicate compatibility with various versions of Windows in your manifest as well. I know that there are entries for compatibility with Vista and Win7; not sure about XP.

Info about the manifest compatibility section is available at MSDN. This may help, also - from the linked page:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
Ken White