2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
c++ , how to delete a binary key in the registry
#349175
12/04/10 16:23
12/04/10 16:23
|
Joined: Oct 2002
Posts: 8,939 planet.earth
ello
OP
Senior Expert
|
OP
Senior Expert
Joined: Oct 2002
Posts: 8,939
planet.earth
|
hi there, can someone point me to how i can delete a certain binary entry in the registry? i can delete a whole key with its content but i cant find some example or info how to delete a certain binary entry...
for example how can i delete HKEY_LOCAL_MACHINE\\SOFTWARE\\MYKEY\\VALUE
thanks in advance, ello
edit: ok, i found this RegDeleteKeyValue.. but how do i use it? i gent an error "error C2664: 'RegDeleteKeyValueW': Konvertierung des Parameters 2 von 'const char [33]' in 'LPCWSTR' nicht möglich"
this is how iwas trying it: RegDeleteKeyValue(HKEY_LOCAL_MACHINE,"HKEY_LOCAL_MACHINE\\SOFTWARE\\MYKEY","VALUE");
Last edited by ello; 12/04/10 16:55.
|
|
|
Re: c++ , how to delete a binary key in the registry
[Re: TechMuc]
#349189
12/04/10 20:20
12/04/10 20:20
|
Joined: Oct 2002
Posts: 8,939 planet.earth
ello
OP
Senior Expert
|
OP
Senior Expert
Joined: Oct 2002
Posts: 8,939
planet.earth
|
thanks for you r help.. what could it be that the value isnt deleted? i have created the value manually in the registry for testing purposes and when i run my program the value still remains. here is my complete code:
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
CHAR strLong[1024];
LONG result;
result = RegDeleteKeyValue(HKEY_LOCAL_MACHINE,L"SOFTWARE\\MYKEY\\",L"VALUE");
printf(strLong, "%s", result);
printf("\n");
system("Pause");
return 0;
}
thanks in advance for any help edit: i tried another way
#include <stdio.h>
#include <windows.h>
int main()
{
HKEY hkey;
LONG result;
result = RegOpenKey(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MYKEY", &hkey);
if(result==ERROR_SUCCESS) printf("key opened");
RegDeleteValue(hkey, L"VALUE");
RegCloseKey(hkey);
system("Pause");
return 0;
}
it seems that the key isnt even opened as the printf is not called. any ideas??
Last edited by ello; 12/04/10 20:41.
www.earthcontrol.dequoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
|
|
|
Re: c++ , how to delete a binary key in the registry
[Re: ello]
#349194
12/04/10 22:26
12/04/10 22:26
|
Joined: Oct 2002
Posts: 8,939 planet.earth
ello
OP
Senior Expert
|
OP
Senior Expert
Joined: Oct 2002
Posts: 8,939
planet.earth
|
hi there.. i have updated the code to get better info about the error
#include <stdio.h>
#include <windows.h>
int main()
{
LONG result;
result = RegDeleteKeyValue(HKEY_LOCAL_MACHINE,L"/SOFTWARE/MYKEY",L"VALUE");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
result,
0,
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, L"Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
return 0;
}
and i am getting "Das System konnte die angegebene Datei nicht finden" any ideas??
|
|
|
|