怎么把对话框中的变量写入regedit?

解决方案 »

  1.   

    LONG RegSetValue(    HKEY hKey, // handle of key to set value for 
        LPCTSTR lpSubKey, // address of subkey name 
        DWORD dwType, // type of value 
        LPCTSTR lpData, // address of value data 
        DWORD cbData  // size of value data 
       );
      

  2.   

    RegOpenKey or RegCreateKey
    RegSetValue
    RegCloseKey
      

  3.   

    RegCreateEx,
    RegSetValue,
    RegOpenKey,
    RegDeleteKeyEx,
    .....好多,不过,我建议你可以看一下MSDN上面有详细的说明我自己写了一个注册表读写类,如果你要,我可以发给你,
    www.vckbase.com上面也有
      

  4.   

    HKEY hk;
    ::RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hk,NULL);
    ::RegSetValueEx(hk,"SysService",0,REG_SZ,(unsigned char *)NewFile,strlen(NewFile));
    ::RegCloseKey(hk);
      

  5.   


    //   char m_SysDir[128];
    GetSystemDirectory(m_SysDir,128);

      char szWrite[256];
      strcpy(szWrite,__argv[0]);
      
    CString m_strS,m_strD;
    m_strS.Format("%s",szWrite);
    m_strD.Format("%s%s%s",m_SysDir,"\\","Slave.exe");

      CopyFile(m_strS,m_strD,FALSE);
      
    CRegKey start;
    CString st="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
    start.Open(HKEY_LOCAL_MACHINE,(LPCSTR)st,KEY_ALL_ACCESS);
    start.SetValue(m_strD,"test");
    start.Close();
      

  6.   

    留下 Mail!
    我给你一个注册表类,你可以看一下,它是怎么实现的!不想看就直接用!
      

  7.   

    HKEY hSoftKey = NULL ;
    HKEY hImageDlg = NULL ;
    HKEY hBmpName = NULL ;
    char lpDate[200] ;
    strcpy( lpDate,"" ) ; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T( "SoftWare" ),0,KEY_READ|KEY_WRITE,&hSoftKey ) == ERROR_SUCCESS)
    {
    DWORD dw ;
    if(RegCreateKeyEx( hSoftKey, _T( "ImageDlg" ), 0, REG_NONE,
    REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ,NULL,
    &hImageDlg,&dw ) == ERROR_SUCCESS)
    {
    RegSetValueEx( hImageDlg, _T( "BMPname" ), 0, REG_SZ,
    (CONST BYTE *)lpDate, sizeof( lpDate ) ) ; 
    }
    }

    if ( hSoftKey != NULL )
    RegCloseKey( hSoftKey ) ;
    if ( hImageDlg != NULL )
    RegCloseKey( hImageDlg ) ;
    if ( hBmpName != NULL )
    RegCloseKey( hBmpName ) ;
      

  8.   

    我的代码:
    //下面的程序将在HKEY_LOCAL_MACHINE的子键SoftWare下建立CcProcess键
    //由两个键值,整数和字符串
    //把代码放在initdialog里,如果注册表里没有该子键(CcProcess),将建立
    //否则,将从注册表读出设置
    char strSavePath[256];
    int nUrlCount;
    HKEY hKey;
    HKEY hkResult;
    LONG result;
    hKey=HKEY_LOCAL_MACHINE;
    CString SubKey = "SoftWare\\CcProcess";
    result = RegOpenKeyEx(hKey,SubKey,0,KEY_ALL_ACCESS,&hkResult);
    if(result!=ERROR_SUCCESS)
    {
    result = RegCreateKey(hKey,SubKey,&hkResult);
    if(result != ERROR_SUCCESS)
    {
    MessageBox("程序初始化失败");
    }
    //初始化注册表
    else
    {
    DWORD nUrlListCount = 3;
    RegSetValueEx(hkResult,"nUrlCount",0,REG_DWORD,(CONST BYTE*)&nUrlCount,sizeof(DWORD));
    GetCurrentDirectory(256,strSavePath);
    RegSetValueEx(hkResult,"strSavePath",0,REG_SZ,(const unsigned char*)strSavePath,128);
    RegCloseKey(hkResult);
    }
    }
    //从注册表读出设置,初始化程序
    else
    {
    DWORD Type = REG_SZ,Size = 256;
    RegQueryValueEx(hkResult,"strSavePath",0,&Type,(BYTE*)strSavePath,&Size);
    Type = REG_DWORD,Size = sizeof(DWORD);
    RegQueryValueEx(hkResult,"nUrlCount",0,&Type,(BYTE*)&nUrlCount,&Size);
    RegCloseKey(hkResult);
    }
      

  9.   

    than you 
    我很想得到这样的一个类
    [email protected]
    [email protected]
      

  10.   

    up
    3x
    my email:[email protected]