C# – Should I use a VirtualStore solution on Vista

c

Because my application need to write settings in Program Files. So, please me choose a solution:
1. Should I use VirtualStore solution when use on Windows Vista & Windows 7?
2. Use manifest to run application with Administator mode.

See this topic: http://forums.techarena.in/vista-help/730258.htm

Please give me some suggestions. Thanks.

And if I use VirtualStore solution, how to know VirtualStore is being used & how to get the VirtualStore's path.

Thank you.

Best Answer

If you're really that lazy and don't want to save the data to the user's application data directory where it belongs, you need to enable virtualization for the process, and then you can write to Program Files while Windows handles the rest.

  • Get a handle to your process token using OpenProcessToken.
  • Enable virtualization for the token by calling SetTokenInformation with TokenVirtualizationEnabled.