07-31-2012 08:25 PM
I'm using LabWindows v8.5.0 installed on a Windows 7 machine. In my application, I can read from both String and number registry key using RegReadString and RegReadULong, but when I try to write to the keys using RegWriteString and RegWriteULong, the function returns a zero indicating it was successful, but the data is not in the registry. I've changed permissions on the key to allow full control to all users listed, but it still doesn't work. Am I missing something?
int RegWriteNum(char *key, unsigned long int val)
ret = RegWriteULong (REGKEY_HKLM, "Software\\Me\\Test", key, val, 0);
if (ret < 0)
err = GetGeneralErrorString(ret);
sprintf(buf, "Registry Read error (%s): %s", key, err);
When I put a breakpoint on the function call, 'key' and 'val' are correct. The function returns '0', but data is not in the registry.
08-01-2012 09:31 AM
When you open LabWindows/CVI, have you tried right-clicking on the shortcut and selecting "Run As Administrator"?
08-02-2012 07:11 AM
Thanks, Kyle. That indeed worked. I would not have thought about trying that for two reasons: (1) I changed the permissions on the key to allow full control for all users, and (2) my login account is an administrator account. It doesn't make sense that either of those would still not allow a registry key to be modified. Any idea what the difference in "run as administrator" and being logged in as administrator is?
08-02-2012 07:26 AM
You can disregard the previous question; I read an article online that somewhat answered my lack of understanding. It would help if I could encounter an article somewhere that explained, briefly, what to look out for in the different versions of Windows. I do have another question though: I read where the OS allows for applications to request a higher privilege; can you point me toward a library function in LabWindows 8.5 that I can incorporate in my application? Thanks for your help.
08-03-2012 08:46 AM
I found an article which describes you can set a program to be Ran As Administrator by default. If that's not sufficient for what you're looking for, could you give me some documentation on the higher privilege request that you're referring to? I'm not familiar.
08-03-2012 09:26 PM
I'm sure there is a property on the shortcut for running as Admin, and I can do that. The article I read mentioned that the recent change (with Vista) was that when an Administrator account logs in, there are two security tokens: one is the normal level that any non-Admin login account gets, and the other is the higher-priviledge token for being an Administrator. The lower level token is the one used by default, and when Run as Administrator is selected, the higher-level token is used. It had verbage that indicated the program itself could request the higher-priviledge token, and I recall running some apps that create a popup relating to the higher priviledge token, so they indeed request the higher-level token themselves. I was wondering if LabWindows had a Library function that would do that.
I appreciate the help; I'll sign-off on this one. Till next time ...
08-04-2012 03:33 AM
I Leland, I read you are running under WIn7 so I thought sharing this discussion with you can be of help: the key point is that starting from Vista on direct acces to the registry is discouraged by Microsoft, which provides different locations where to put data your application needs. This discussion also can clarify some concept.