I'm trying to programmatically set a static ip address / gateway /
mask on my device. There's no API so far as I'm aware so I've tried
writing directly to the registry.
Dumping the registry before and after setting a static IP address
manually gives me:
[HKEY_LOCAL_MACHINE\Comm\P5001\Parms\TcpIp]
"DefaultGateway"=hex(7):\
32,32,32,2e,32,32,32,2e,32,32,32,2e,32,32,32,00,00,00,00
"Subnetmask"=hex(7):\
...
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WZCSVC\Parameters]
"ContextSettings"=hex:\
b8,0b,00,00,00,00,00,70,d0,07,00,00,89,13,00,00,88,13,00,00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces
\P5001]
"ActiveSettings"=hex:\
b4,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
...
But after writing these values in manually, the ip addresses dialog
comes up with empty entries.
If I dump the registry now I get
[HKEY_LOCAL_MACHINE\Comm\P5001\Parms\TcpIp]
"DefaultGateway"=hex:\
32,32,32,2e,32,32,32,2e,32,32,32,2e,32,32,32,00,00,00,00
You'll notice that the registry type in the first case is hex(7):\ and
in the second is just hex:\
Could this be why I'm not setting these values correctly? I can't see
any way of writing a registry type as hex(7) vs hex
RegSetValueEx(m_hkey, pcszKey, 0, REG_BINARY, (PBYTE)pData, cbData)
Thanks for any suggestions.