0

Disabling Windows 7 Virtual Store can be done manually by the following:

"Go to the new Virtual Directory application folder that Windows 7 created, then right click > Properties > Security Tab > Edit and if the Local Computer (Users) account is not listed, then add it and set the permissions to Full Control and save all the way out of the properties. (Darien Smith: Systems Engineer)"

Is there a way to do that by code using C++Builder XE or Delphi? And how to check if it Disabled/Enabled?

Ediz Asker
  • 51
  • 1
  • 7

2 Answers2

8

You need to add a manifest to your application (preferably by embedding it as a resource - see the articles I've linked at the end of this answer for details). From Create and Embed a Manifest (UAC) at MSDN

Sample application manifest file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="App" version="3.1.0.0" processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
        </requestedPrivileges>
    </security>
  </trustInfo>
  <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>
</assembly>

There's information on adding the manifest to a Delphi/C++ Builder application in uac - How to add manifest into Delphi project?, and step-by-step instructions for embedding the manifest in a Delphi application here.

Community
  • 1
  • 1
Ken White
  • 123,280
  • 14
  • 225
  • 444
  • This seems to recommend placing the manifest in a separate file alongside the executable. It should be embedded. – David Heffernan Feb 22 '14 at 06:28
  • 1
    @DavidHeffernan, both ways will work, but 5.x prefers file, and 6.x prefers resource. – Free Consulting Feb 22 '14 at 19:33
  • 1
    @Free It's always better to embed to avoid oddities when users copy or rename executables. – David Heffernan Feb 22 '14 at 19:35
  • @David: MSDN provided the majority of the information, and *you* provided one of the answers to the post I linked on SO (which explains how to add it to a Delphi/Builder application). If MSDN's information is incorrect, contact Microsoft. If yours is wrong or incomplete, you should edit your answer to correct it. :-) (The third answer to the SO post shows how to embed the resource in a Delphi app.) – Ken White Feb 22 '14 at 19:48
  • @Ken You should explicitly recommend embedding. – David Heffernan Feb 22 '14 at 19:58
  • Thank you @KenWhite, Sir Rufo, and David Heffernan. I did create manifest file for my exe by placing the manifest in a separate file alongside the executable (POS.exe.manifest). But Windows show me a message that i Cannot write on the Ini file or database file (Financial_Data.accdb)? – Ediz Asker Feb 22 '14 at 20:19
  • @EdizAsker Disabling Virtual Store redirection, means your probably trying to write to Program Files, which is read only without Admin access, since Windows Vista. You need to change your program to store its data files in the correct place, such as AppData or ProgramData. – stukelly Mar 18 '14 at 20:46
1

The correct way to mark your application as not virtualized is to link an application manifest to it.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490