LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

windows 7 registery

Hi,

 

I have just upgraded my development PC from Windows XP Prof to Windows 7 Prof.

 

This has introduced a problem with an application that was working fine on XP.

 

Under Windows 7 I am unable to write to the following registry key:

 

char * subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";

 

const char * title = "OB5 Scheduler";

 

 

GetProjectDir (executablePath);
SetDir (executablePath);
strncat(executablePath , "\\" , MAX_PATHNAME_LEN - strlen(executablePath));
strncat(executablePath , argv[0] , MAX_PATHNAME_LEN - strlen(executablePath));

 

GetProjectDir (executablePath);

SetDir (executablePath);

strncat(executablePath , "\\" , MAX_PATHNAME_LEN - strlen(executablePath));

strncat(executablePath , argv[0] , MAX_PATHNAME_LEN - strlen(executablePath));

 

RegWriteString (REGKEY_HKLM, subkey, title, executablePath);

 

The function returns -5066 = "Could not set data for registry value".

 

 

I be grateful for pointers.

 

John C
0 Kudos
Message 1 of 7
(3,983 Views)

The registry is more protected in Windows Vista and Windows 7 than in previous versions of Windows. In order to change any key in HKLM, avoiding virtualization*, your application will need to be run with administrative privileges (right-click 'run as administrator' option). There are a number of ways of ensuring this happens automatically, perhaps the most correct being to add a manifest to the exe to requiest administrative rights each time the app. is run.

 

*Virtualization doesn't apply to HKLM\Software\Microsoft\Windows and sub-keys in any case.

--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 7
(3,942 Views)

Thanks for the reply Martin,

 

A quick search on manifest files brings up a lot of potential reading. Do you have any suggestions for a good place to start?

 

Thanks,

 

John

John C
0 Kudos
Message 3 of 7
(3,939 Views)

I'm no expert, but if you search for articles that also contain "requireAdministrator" (one word), you might find something useful. You are looking for some XML that will form the manifest file which you can then embed in your application using the Build|Target Settings dialog.

 

Microsoft have a tool called 'MageUI' which can generate manifest files, it is part of the .NET framework toolset.

--
Martin
Certified CVI Developer
0 Kudos
Message 4 of 7
(3,930 Views)

Thanks Martin,

 

I'll take a look at that.

 

John

John C
0 Kudos
Message 5 of 7
(3,928 Views)

Don't forget to post your findings back here - that way we all learn Smiley Happy

--
Martin
Certified CVI Developer
0 Kudos
Message 6 of 7
(3,886 Views)

Will do, but this is a background task for me.

 

John

John C
0 Kudos
Message 7 of 7
(3,883 Views)