simple code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
HKEY hkey;
char home[] = "http://www.baidu.com";
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Internet Explorer\\MAIN",
0, KEY_WRITE, &hkey))
{
fprintf(stderr, "error open main key!\n");
return 1;
}
if( ERROR_SUCCESS != RegSetValueEx(hkey, "Start Page",
0, REG_SZ, (const BYTE *)home, sizeof(home) + 1))
{
fprintf(stderr, "error write key value!\n");
return 2;
}
printf("change IE home page sucessful!\n");
RegCloseKey(hkey);
return 0;
}
你可以参考上面的说明。
http://msdn.(v=vs.85)
-----------------
lpData [in]
The data to be stored.
For string-based types, such as REG_SZ, the string must be null-terminated. With the REG_MULTI_SZ data type, the string must be terminated with two null characters. String-literal values must be formatted using a backslash preceded by another backslash as an escape character. For example, specify "C:\\mydir\\myfile" to store the string "C:\mydir\myfile".
REG_MULTI_SZ 如果是多字符串类型必须以2个null字符结尾。
[
本帖最后由 hellovfp 于 2012-7-24 11:27 编辑 ]