注册 登录
编程论坛 C++教室

一个关于注册表的问题

dome14426 发布于 2010-04-20 16:31, 384 次点击
#include <windows.h>
#include <stdio.h>
int main()
{
    //通过修改注册表来设置QQ为开机启动
unsigned char szStart[100]="D:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe";
char szNotKnow[128]="QQ";
HKEY hKey;
LONG lnRes=RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                        "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
                        0L,
                        KEY_WRITE,
                        &hKey);
if(lnRes==ERROR_SUCCESS)
{
    //打开成功
    lnRes=RegSetValueEx(hKey,
        szNotKnow,
        0,
        REG_SZ,
        szStart,
        REG_SZ);
    printf("%s\n",szStart);
    if(lnRes==ERROR_SUCCESS)
        printf("加载成功!\n");

}
   
   
    return 0;
}

这个程序是能对注册表做点操作,但是就是不能把值赋过去 ,最终不能在开机启动的时候运行QQ。不知道是哪里出了问题,还望高手指教!
0 回复
1