本帖最后由 gjskxy 于 2010-05-18 16:43:06 编辑

解决方案 »

  1.   

    给你一个设置开机启动的函数
    你参考一下
    void CWinFunc::SetAutoStart(BOOL bEnable, CString strRegValue)
    {
    HKEY hKey;
    LONG lRet=RegCreateKeyEx(_hAutoRunRootKey, REG_AUTORUNSUBKEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &_dwDisposition); if(lRet!=ERROR_SUCCESS)
    {
    ASSERT(lRet);
    return;
    } if(bEnable)
    {
    if(IsAutoStart(strRegValue))
    return; char szModule[255];
    ::GetModuleFileName(NULL, szModule, 255); lRet=RegSetValueEx(hKey, strRegValue, 0, REG_SZ, (BYTE*)szModule, (DWORD)strlen(szModule)); if(lRet!=ERROR_SUCCESS)
    {
    ASSERT(lRet);
    return;
    }
    }else
    {
    RegDeleteValue(hKey, strRegValue);
    } RegCloseKey(hKey);
    }
      

  2.   

    HKEY hkey;
    RegCreateKey(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\xxxx"),&hkey);  创建项
    RegSetValueEx(hkey,"xxxx",NULL,REG_DWORD,(CONST BYTE*)&xxxx,xxxx); 创建键值RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\xxxx",NULL,KEY_ALL_ACCESS,&hkey))  打开项RegQueryValueEx(hkey,"xxxx",NULL,NULL,(LPBYTE)&readbuf,&lenth)  读取键值具体使用方法可以查msdn