Registry Corruption
-
Hi I am writing a program which Creates Three entries into the windows registry but on some systems instead of creating the registry it locks the registry HKEY_LOCAL_MACHINE\SOFTWARE part and shows error "Access is denied" and after that it does not allow to create a entry into the registry, it seems that registry got corrupted but windows still works fine. I don't know. Is it the problem of Rights to write into the registrry or something else.This program works fine on my machine but does not works on some machines. Please help... BOOL CGenUniqueKeyXDlg::SaveValueToRegistry(char *pcszValue) { DWORD dwLen = 0; int nReturnVal; HKEY m_hContextKey; DWORD dwDisp; nReturnVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE , //Handle to a currently open key REG_LOC_PATH, // Sub Key Name 0, //Reserved NULL, 0, KEY_WRITE, NULL, &m_hContextKey, &dwDisp ); if(nReturnVal != ERROR_SUCCESS) { ShowRegError(nReturnVal); return FALSE; } nReturnVal = RegSetValueEx(m_hContextKey, UNIQUE_KEY, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); if(nReturnVal != ERROR_SUCCESS) { ShowRegError(nReturnVal); return FALSE; } strcpy(pcszValue,m_SyncURL);//"http://Nopd/CiteCapture/MDCSync.aspx"; nReturnVal = RegSetValueEx(m_hContextKey, URL_KEY, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); strcpy(pcszValue,m_Port); nReturnVal = RegSetValueEx(m_hContextKey, COM_PORT, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); RegCloseKey( m_hContextKey ); return TRUE; } Any input will be appreciated Thanks Shailesh
-
Hi I am writing a program which Creates Three entries into the windows registry but on some systems instead of creating the registry it locks the registry HKEY_LOCAL_MACHINE\SOFTWARE part and shows error "Access is denied" and after that it does not allow to create a entry into the registry, it seems that registry got corrupted but windows still works fine. I don't know. Is it the problem of Rights to write into the registrry or something else.This program works fine on my machine but does not works on some machines. Please help... BOOL CGenUniqueKeyXDlg::SaveValueToRegistry(char *pcszValue) { DWORD dwLen = 0; int nReturnVal; HKEY m_hContextKey; DWORD dwDisp; nReturnVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE , //Handle to a currently open key REG_LOC_PATH, // Sub Key Name 0, //Reserved NULL, 0, KEY_WRITE, NULL, &m_hContextKey, &dwDisp ); if(nReturnVal != ERROR_SUCCESS) { ShowRegError(nReturnVal); return FALSE; } nReturnVal = RegSetValueEx(m_hContextKey, UNIQUE_KEY, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); if(nReturnVal != ERROR_SUCCESS) { ShowRegError(nReturnVal); return FALSE; } strcpy(pcszValue,m_SyncURL);//"http://Nopd/CiteCapture/MDCSync.aspx"; nReturnVal = RegSetValueEx(m_hContextKey, URL_KEY, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); strcpy(pcszValue,m_Port); nReturnVal = RegSetValueEx(m_hContextKey, COM_PORT, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); RegCloseKey( m_hContextKey ); return TRUE; } Any input will be appreciated Thanks Shailesh
aman2006 wrote: ...but on some systems instead of creating the registry it locks the registry HKEY_LOCAL_MACHINE\SOFTWARE part and shows error "Access is denied"... Are you sure you have 'write' permission on those particular machines? Much like you can with folders and shares, the registry can be tuned to allow/disallow certain users/groups.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
aman2006 wrote: ...but on some systems instead of creating the registry it locks the registry HKEY_LOCAL_MACHINE\SOFTWARE part and shows error "Access is denied"... Are you sure you have 'write' permission on those particular machines? Much like you can with folders and shares, the registry can be tuned to allow/disallow certain users/groups.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
If i don't have write permission on that machine how can i write my entries in the Registry. In my code i am passing the Write Registry Permission as a parameter. Actuall i have made a installable with installed shield which runs my program at last for creating some entries. But it is corrupting the registry.... What about code is that fine or seems some problem????? thnaks Shailesh
-
If i don't have write permission on that machine how can i write my entries in the Registry. In my code i am passing the Write Registry Permission as a parameter. Actuall i have made a installable with installed shield which runs my program at last for creating some entries. But it is corrupting the registry.... What about code is that fine or seems some problem????? thnaks Shailesh
One way to tell would be to use regedit.exe to try and write something to the same spot in the registry as the code is. Be sure and log in using the same credentials as the person running your code.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
Hi I am writing a program which Creates Three entries into the windows registry but on some systems instead of creating the registry it locks the registry HKEY_LOCAL_MACHINE\SOFTWARE part and shows error "Access is denied" and after that it does not allow to create a entry into the registry, it seems that registry got corrupted but windows still works fine. I don't know. Is it the problem of Rights to write into the registrry or something else.This program works fine on my machine but does not works on some machines. Please help... BOOL CGenUniqueKeyXDlg::SaveValueToRegistry(char *pcszValue) { DWORD dwLen = 0; int nReturnVal; HKEY m_hContextKey; DWORD dwDisp; nReturnVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE , //Handle to a currently open key REG_LOC_PATH, // Sub Key Name 0, //Reserved NULL, 0, KEY_WRITE, NULL, &m_hContextKey, &dwDisp ); if(nReturnVal != ERROR_SUCCESS) { ShowRegError(nReturnVal); return FALSE; } nReturnVal = RegSetValueEx(m_hContextKey, UNIQUE_KEY, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); if(nReturnVal != ERROR_SUCCESS) { ShowRegError(nReturnVal); return FALSE; } strcpy(pcszValue,m_SyncURL);//"http://Nopd/CiteCapture/MDCSync.aspx"; nReturnVal = RegSetValueEx(m_hContextKey, URL_KEY, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); strcpy(pcszValue,m_Port); nReturnVal = RegSetValueEx(m_hContextKey, COM_PORT, 0, REG_SZ, (PBYTE)pcszValue, (_tcslen(pcszValue) + 1) * sizeof(char)); RegCloseKey( m_hContextKey ); return TRUE; } Any input will be appreciated Thanks Shailesh
You're asking for write access to a key under HKLM.
RegCreateKeyEx()
is returning access denied, which means the user doesn't have write privileges to that key. Run your code as a restricted user (not admin) and you'll see the same error. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- #include "witty-quote.h"