Registry

I need a code to put my program in the
registry
to start up automatically. I know about the startup folder, but I don't know how to copy files or how to check for different versions of windows and make it copy a file by using an if statement. The code needs to work for C++/CLI.
With .Net it is easy: http://msdn.microsoft.com/en-us/library/system.environment.aspx . Look for OSVersion. It will help you determine the Windows version your program is running on.

As for file copying, study the System::IO namespace.

For the registry, use the classes in the Microsoft::Win32 namespace.

Finally, a clarification: This forum has been traditionally for unmanaged C++; I recommend you to post @ MSDN Online (http://social.msdn.microsoft.com/forums) for speedier and more accurate answers about C++/CLI and the .Net framework.
This couldn't be more perfect of a match if it had been written in response to this: http://msdn.microsoft.com/en-us/library/bwt6b955.aspx
Thanks, and do you know a way so I can write a text file into
C:\Program Files
It doesnt' let me, even when I click run as administrator.
The fact that you CAN click Run as administrator tells me that you are running in Vista or 7. If that's the case that account is actually disabled by default, you should make sure it's enabled before you try to use it.
closed account (3hM2Nwbp)
http://codeoflegend.blogspot.com/2011/04/ccli-writing-to-windows-registry.html

With a bit more information about exactly what may happen should the calls fail with exceptions. IMO example code shouldn't be ambiguous in any aspect, that includes lumping exceptions into their base class to hide them.
Last edited on
Topic archived. No new replies allowed.