我用RegSetValueEx在注册表里增加了一个DWORD值,但我打开注册表查看时却显示 
“不正确的DWORD值”
比如 : 我要 建立一个 DWORD值, 键名为“MustBeValidated”,其十六进制值为“1”   用vc++6.0该怎么写代码啊?

解决方案 »

  1.   

    from msdn:
    void AddEventSource()
    {
        HKEY hk; 
        DWORD dwData; 
        UCHAR szBuf[80]; 
     
        // Add your source name as a subkey under the Application 
        // key in the EventLog registry key. 
     
        if (RegCreateKey(HKEY_LOCAL_MACHINE, 
                "SYSTEM\\CurrentControlSet\\Services\ 
                \\EventLog\\Application\\SamplApp", &hk)) 
            ErrorExit("Could not create the registry key."); 
     
        // Set the name of the message file. 
     
        strcpy(szBuf, "%SystemRoot%\\System\\SamplApp.dll"); 
     
        // Add the name to the EventMessageFile subkey. 
     
        if (RegSetValueEx(hk,             // subkey handle 
                "EventMessageFile",       // value name 
                0,                        // must be zero 
                REG_EXPAND_SZ,            // value type 
                (LPBYTE) szBuf,           // pointer to value data 
                strlen(szBuf) + 1))       // length of value data 
            ErrorExit("Could not set the event message file."); 
     
        // Set the supported event types in the TypesSupported subkey. 
     
        dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | 
            EVENTLOG_INFORMATION_TYPE; 
     
        if (RegSetValueEx(hk,      // subkey handle 
                "TypesSupported",  // value name 
                0,                 // must be zero 
                REG_DWORD,         // value type 
                (LPBYTE) &dwData,  // pointer to value data 
                sizeof(DWORD)))    // length of value data 
            ErrorExit("Could not set the supported types."); 
     
        RegCloseKey(hk); 
    }
      

  2.   

    Thank you for giving you source code!!!