I have a program that works fine in Win98 and WinXP. Vista apparently will not let my program modify the registry.
1) My program needs to save the path to the files it will work with in the registry.
Is there a better hKey to use than HKEY_CURRENT_USER? Or will Vista just not allow me to change the registry?
2) I add various options to the context menu for certain extensions. This "used to be done" by adding the following keys:
Is this still the correct process, or has Vista completely changed this?
1) My program needs to save the path to the files it will work with in the registry.
Code:
long GetOrCreateRegistryInfoInt( char *keyname, long defaultvalue, long &keyval )
{
HKEY hKey ;
DWORD dwDispose ;
keyval = defaultvalue ;
long result = RegCreateKeyEx( HKEY_CURRENT_USER, "Software\\NameOfCompany", 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_READ | KEY_WRITE, NULL, &hKey, &dwDispose ) ;
if ( result == ERROR_SUCCESS )
{
if ( dwDispose == REG_CREATED_NEW_KEY )
{
result = RegSetValueEx( hKey, keyname, 0, REG_DWORD,
( UCHAR* )&defaultvalue, sizeof( long ) ) ;
}
else
{
ULONG size = sizeof( long ) ;
result = RegQueryValueEx( hKey, keyname, 0, NULL,
( UCHAR* )&keyval, &size ) ;
}
RegCloseKey( hKey ) ;
}
return result ;
}
2) I add various options to the context menu for certain extensions. This "used to be done" by adding the following keys:
Code:
HKEY_CLASSES_ROOT\.bmp = Paint Picture
HKEY_CLASSES_ROOT\Paint.Picture = Bitmap Image
// these 2 should already be in most people's registries
HKEY_CLASSES_ROOT\Paint.Picture\shell\My_New_Command\command = {myapp} "%1"
// this adds "My_New_Command to the context menu for .bmp files
// {myapp} is the full path to my application.