Problem with RegQueryValueEx()

Started by pitter2206, April 15, 2010, 05:27:27 PM

Previous topic - Next topic

pitter2206

Hi guys,

I´ve got a problem with reading in the registry...

I want to look if the string of the following BTStatus is "1" or "0":
[HKEY_LOCAL_MACHINE\GoPal]
"BTStatus"="1"

If the BTStatus = 0  I want to do nothing...

So... my problem is, that I can´t test it here, because I am fixing a problem of a friend of mine...

I´ve got this code to read the string of a entry:

#include <windows.h>
#include <windowsx.h>

HKEY hkey;


int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
CreateProcess(L"\\My Flash Disk\\Navigation\\mnavdce.exe\0",NULL,0,0,FALSE,0, 0, 0, NULL, NULL);
Sleep(5000);

DWORD dwData = 256;
BYTE cDaten[256] = "";
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"GoPal", 0, KEY_READ, &hkey)== ERROR_SUCCESS);
{
RegQueryValueEx(hkey, L"BTStatus",0,0,cDaten,&dwData);
if (cDaten == "1");
{
CreateProcess(L"\\My Flash Disk\\Bluetooth\\PhoneLink.exe\0",NULL,0,0,FALSE,0, 0, 0, NULL, NULL);
}
}
RegCloseKey(hkey);
return 0;
}


please... could someone have a look if something is wrong with it please?  ???

I get an error-message while creating the Exe:
main.c(18): error #2168: Operands of == have incompatible types 'unsigned char *' and 'char *'.

AlexN

Quote from: pitter2206 on April 15, 2010, 05:27:27 PM

main.c(18): error #2168: Operands of == have incompatible types 'unsigned char *' and 'char *'.

To compare strings, you need the function strcmp(char *s1, char *s2).

If you want to test it, you can try, if your code works for a PC.

To test your code at your friend you can copy Pelles C on an USB-stick and use the command-line-option /x for POIDE (look into the help, how to use it).

best regards
Alex ;)

TimoVJL

Is that key under SOFTWARE\GoPal ??
May the source be with you

pitter2206

#3
Hi timovjl,
no it is as shown under HKLM

TimoVJL

if (cDaten[0] == '1')
Removed that ';' from line end too
May the source be with you

pitter2206

YES Sir!!! It works fine!

Thanks a lot!!!