LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not read windows registry (cvi 6)

Hello ,

I have made such a code phase to write/read windows registry key value , but can not get the correct result :
.....
unsigned char instMode = 0;
......
RegWriteBinary (REGKEY_HKLM, "Software\\Myfile\\INSTALLMODE", "INSTMODE",&instMode, 1); //write 0 to the registry

......
for the read function :
RegReadBinary (REGKEY_HKLM, "Software\\POWERVIEW\\INSTALLMODE", "INSTMODE", ?, ?,?);
I do not know how to set the "?" item so that I can read out the correct value .Please provide an anwser .Thanks .

David
0 Kudos
Message 1 of 3
(2,973 Views)
Sorry ,I can get the value in debug status ,e.g.,
......
unsigned char tmp1[1];
int val;

RegReadBinary (REGKEY_HKLM, "Software\\POWERVIEW\\INSTALLMODE", "INSTMODE", tmp1, 1,&tmp),the value of tmp1 is 0 , but if make such a sentence : val = tmp1[0] ,I can just get 48 ,which means the corresponding ascii code is 48 .Which function can be used to get the real value (0) not the ascii value ?

David
0 Kudos
Message 2 of 3
(2,973 Views)
David,

If you want to read and write a string from the registry you should use RegWriteString() and RegReadString() instead of RegWriteBinary(). This way you'll avoid data casting and management. However to transform an integer to a string you can just read it as a char and put it into a string.

char1 = (char)(int1&0x00000011);

I hope this helps.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 3 of 3
(2,973 Views)