编辑注册表值 [英] Edit Registry Values

查看:139
本文介绍了编辑注册表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改PocketPC上的注册表值.我运行了以下代码:

I want to change the registry values on the pocketPC. I ran the following code:

if(enabled)
{
    dwData = 120;
}
if(RegSetValueEx(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Power\\Timeouts\\BattSuspendTimeout"), 0, REG_DWORD, (LPBYTE)&dwData, sizeof(DWORD)))
{
    return FALSE;
}

但是它不会修改注册表项.有谁知道如何使用c ++设置注册表项值?

but it doesn't shange the registry entry. Does anyone know how to set registry key values with c++?

谢谢!

推荐答案

您正在做的事情有两个问题:

There are a two problems with what you are doing:

1:RegSetValueEx不采用路径,仅采用值名称.因此,您需要先打开密钥路径.

1: RegSetValueEx does not take a path, only a valuename. So you need to open the key path first.

例如

HKEY key;
if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Power\\Timeouts", 0, 0, &key))
{
    if(RegSetValueEx(key, _T("BattSuspendTimeout"), 0, REG_DWORD, (LPBYTE)&dwData, sizeof(DWORD)))
    {
        RegCloseKey(key);
        return FALSE;
    }

    RegCloseKey(key);
}

2:注册表的该区域要求特权代码签名才能在所有Windows Mobile设备上工作.如果用户在首次运行或安装该应用程序时对未知的发布者问题回答是",则可以在大多数当前的触摸屏Windows移动设备上使用它.如果您在设备上收到访问被拒绝"错误,则确实需要对特权代码进行签名才能使设备工作.

2: That area of the registry requires Privileged code signing to work on all Windows Mobile devices. You can get away with it on most current touch-screen windows mobile devices if the user says "yes" to the unknown publisher question when the application is first run or installed. If you get a "Access Denied" error on the set, then you really need to be Privileged code signed for the set to work.

这篇关于编辑注册表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆