Archived

This topic is now archived and is closed to further replies.

Squirrel

registry problems - HELP!

Recommended Posts

Squirrel    122
I've been waiting so long to figure this out from an other forum but no one seems to know how. I have the folowing code: if(RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\internet settings"), 0, NULL, 0, 0, NULL, &hkey, &dwDisposition)==ERROR_SUCCESS) { dwType = REG_BINARY; RegSetValueEx(hkey, TEXT("EnableAutoDial"), 0, dwType,(PBYTE)"01 00 00 00", dwSize);RegCloseKey(hkey); } I don't really know it by heart, it was just given to me and it works. The problem is, It was first as REG_SZ (or whatever it is for strings) but I need it to be binary. The problem is, it does not work. When I go in the registry after running this, it will say something like "zero-leght number" or something like that. What is wrong? How to I put it in? I noticed that putting 01 00 00 00 is not the correct way. I tried using ' and " to seperate it. I tried putting . and , between each 2 number. I tried not putting spaces. Nothing. Please help me! I need to do this bad. Also, is there an easyer way to access the registry? This code is nuts and I alwasy have to copy and paste it from a txt file where I keep all the complicated commands like winmain for example. Please help me with this. I will fix one of my computer problems since all I'll have to do is put it in a while(1) loop. The problem I'm having is that this setting always changes back to 00 00 00 00 which stops me from connecting to the net. I'm tired of changing it manualy. Thanks! Ryan edit: oh and I don't have MVC++ so if you give me any other commands, make sure it's Borland c++ compatible. I wish I had VC++ though, 99% of all commands only work with that. Edited by - squirrel on November 11, 2001 3:22:36 PM

Share this post


Link to post
Share on other sites
Dean Harding    546
You need to use RegSetValueEx() to set a value, like this:

  
int value = 1;
HKEY hKey;
.
RegOpenKeyEx( HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), 0, KEY_WRITE, &hKey );
RegSetValueEx( hKey, _T("Name"), 0, REG_BINARY, &value, sizeof(value) );


Here, "Name" is the name of the value you''re trying to set.

So after running this, if you look at the registry and go to HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings and look at the "Name" value, it''ll be set to 01 00 00 00.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
Squirrel    122
Tried that too, it still gives my (zero-length binary value)! the first time I ran the program it put 00 00 00 00 and the after that it game me the (zero...) thing. I''ll keep on playing with it though. I did remember to put the & before the intergar too. Thanks though!

Share this post


Link to post
Share on other sites