HKEY hk; DWORD dwData, dwDisp; // Create the event source as a subkey of the log. if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\Microsoft\Windows\CurrentVersion\Internet Settings", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, &dwDisp)) { printf("Could not create the registry key."); return 0; }// Set the name of the message file. dwData = 1; if (RegSetValueEx(hk, // subkey handle L"TypesSupported", // value name 0, // must be zero REG_DWORD, // value type (LPBYTE) &dwData, // pointer to value data sizeof(DWORD))) // length of value data { printf("Could not set the supported types."); RegCloseKey(hk); return 0; }RegCloseKey(hk); 大概就这样吧,看看MSDN里面RegSetValueEx的例子
if (RegSetValueEx(hk, // subkey handle L"ProxyEnable", // value name 0, // must be zero REG_DWORD, // value type (LPBYTE) &dwData, // pointer to value data sizeof(DWORD))) // length of value data { printf("Could not set the supported types."); RegCloseKey(hk); return 0; }
DWORD dwData, dwDisp; // Create the event source as a subkey of the log. if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\Microsoft\Windows\CurrentVersion\Internet Settings",
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &hk, &dwDisp))
{
printf("Could not create the registry key.");
return 0;
}// Set the name of the message file.
dwData = 1;
if (RegSetValueEx(hk, // subkey handle
L"TypesSupported", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwData, // pointer to value data
sizeof(DWORD))) // length of value data
{
printf("Could not set the supported types.");
RegCloseKey(hk);
return 0;
}RegCloseKey(hk); 大概就这样吧,看看MSDN里面RegSetValueEx的例子
L"ProxyEnable", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwData, // pointer to value data
sizeof(DWORD))) // length of value data
{
printf("Could not set the supported types.");
RegCloseKey(hk);
return 0;
}
CRegKey reg;
reg.Open(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\KuGoo\\PartnerProgam"));
reg.SetDWORDValue(TEXT("LastError"), 1);
reg.Close();
HKEY hk;
::RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\KuGoo\\PartnerProgam"), NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, NULL);
::RegSetValueEx(hk, TEXT("LastError"), NULL, REG_DWORD, (BYTE*)&var, sizeof(var));
::RegCloseKey(hk);
他的代码我搞懂了,完全搞定,下面的朋友也辛苦了,但是我没用上也给五分