|
-
Jul 23rd, 2003, 10:22 PM
#1
Thread Starter
Hyperactive Member
Windows not automatically detecting registry changes
I have an app that disables some of the log on features, like HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr, and the registry will see the changes, but Windows won't acknowledge the changes until my app closes. However, if I make the changes directly into the registry editor, Windows will acknowledge the changes. What's the deal? Is this atleast supposed to happen, because if so I don't think it will hurt the functionality of my app; I just don't want to have to worry about differences between different systems.
I'm using Windows XP by the way, and this app is designed for XP.
-
Jul 24th, 2003, 01:22 AM
#2
make sure you're closing the registry key!
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jul 24th, 2003, 08:19 AM
#3
Thread Starter
Hyperactive Member
Hah, thanks for that thought, but I've already looked into that. Same problem.
-
Jul 24th, 2003, 01:20 PM
#4
Why not post some code up and we'll have a look see.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 24th, 2003, 05:53 PM
#5
Thread Starter
Hyperactive Member
Registry Code:
PHP Code:
BOOL SaveDWORD (HKEY lpszKey, LPCTSTR lpszSubkey, LPCTSTR lpszValueName, DWORD dwValue)
{
//Registry Key Handle
HKEY CurKey;
BOOL fRes=FALSE;
if (lpszSubkey != NULL && lpszValueName != NULL)
{
if (strlen(lpszSubkey) > 0 && strlen(lpszValueName) > 0)
{
if (RegOpenKey(lpszKey, lpszSubkey, &CurKey) == ERROR_SUCCESS)
{
if (RegSetValueEx(CurKey, lpszValueName, 0, REG_DWORD, (PBYTE)&dwValue, sizeof(DWORD)) == ERROR_SUCCESS)
fRes = TRUE;
}
else
{
// Create new key
if (RegCreateKey(lpszKey, lpszSubkey, &CurKey) == ERROR_SUCCESS)
{
if (RegSetValueEx(CurKey, lpszValueName, 0, REG_DWORD, (PBYTE)&dwValue, sizeof(DWORD)) == ERROR_SUCCESS)
fRes = TRUE;
}
}
}
}
RegCloseKey (CurKey);
return fRes;
}
Program close code:
PHP Code:
PostQuitMessage(0);
Registry settings being modified:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableChangePassword
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableLockWorkstation
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\NoLogoff
To reiterate: I know the save code works because the registry values do change; the issue is that Windows (XP) doesn't aknowledge the changes with the login screen until my app closes.
As bad as it may look, I'm not trying to write a virus or anything Another question that goes with this, how do I determine the logged on user's permissions (login name, administrative account or limited acount, registry permissions)? Thanks.
-
Jul 28th, 2003, 08:23 AM
#6
Frenzied Member
RegOpenKey, RegCreateKey, and RegSetValue are 16-bit
Windows and should not be used anymore.
RegOpenKeyEx, RegCreateKeyEx, and RegSetValueEx should be used.
Code:
BOOL SaveDWORD(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, DWORD dwValue)
{
HKEY hCurKey;
BOOL bRet = FALSE;
if (lpSubKey != NULL && lpValueName != NULL)
{
if (strlen(lpSubKey) > 0 && strlen(lpValueName) > 0)
{
if (RegOpenKeyEx(hKey, lpSubKey, 0, KEY_SET_VALUE, &hCurKey) == ERROR_SUCCESS)
{
if (RegSetValueEx(hCurKey, lpValueName, 0, REG_DWORD,
(LPBYTE)&dwValue, sizeof(DWORD)) == ERROR_SUCCESS)
{
bRet = TRUE;
}
}
else
{
if (RegCreateKeyEx(hKey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE, NULL, &hCurKey, NULL) == ERROR_SUCCESS)
{
if (RegSetValueEx(hCurKey, lpValueName, 0, REG_DWORD,
(LPBYTE)&dwValue, sizeof(DWORD)) == ERROR_SUCCESS)
{
bRet = TRUE;
}
}
}
}
}
RegCloseKey(hCurKey);
return bRet;
}
Last edited by wey97; Jul 28th, 2003 at 08:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|