标题:【红烧小鲫鱼】注册表API的RegSetValueEx怎么使用啊?
只看楼主
qq492927689
Rank: 1
等 级:新手上路
帖 子:28
专家分:5
注 册:2011-4-27
结帖率:66.67%
已结贴  问题点数:10 回复次数:3 
【红烧小鲫鱼】注册表API的RegSetValueEx怎么使用啊?
我主要是不会用RegSetValueEx中的参数,里面的参数的类型我看不懂。

我想将 "http:\\www.baidu.com" 设置到 HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main 中的
 "Start Page" 里面。请问代码如何写呢?

注:请将数据赋值到一个标识符中,因为我要看一看这个函数中参数的类型是如何设置的!特别是第五个参数
【lpData Any,包含数据的缓冲区中的第一个字节 】这个参数我果真不是很明白!求高手赐代码。


【红烧小鲫鱼】

搜索更多相关主题的帖子: Microsoft Internet Explorer 
2012-07-24 07:41
netlin
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:24
帖 子:544
专家分:4308
注 册:2012-4-9
得分:0 
很多Ghost系统里都有这么做的,打开研究一下!

做自己喜欢的事!
2012-07-24 10:40
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
得分:10 
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 编辑 ]

我们都在路上。。。。。
2012-07-24 11:25
qq492927689
Rank: 1
等 级:新手上路
帖 子:28
专家分:5
注 册:2011-4-27
得分:0 
2楼!感谢了!
2012-07-24 18:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-373981-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.719320 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved