我的代码如下:
RegCreateKey(HKEY_LOCAL_USERS, 
            "Software", a)

解决方案 »

  1.   

    RegCreateKey(HKEY_CURRENT_USER, 'Software\aaa', a);
    RegCreateKey(HKEY_LOCAL_MACHINE, 'Software\aaa', a);
      

  2.   

    函數API聲明如下:
    function RegCreateKey(hKey: HKEY; lpSubKey: PChar;
      var phkResult: HKEY): Longint; stdcall;ParametershKeyIdentifies a currently open key or any of the following predefined reserved handle values: HKEY_CLASSES_ROOT
    HKEY_CURRENT_USER
    HKEY_LOCAL_MACHINE
    HKEY_USERS
    The key opened or created by this function is a subkey of the key identified by hKey. lpSubKeyPoints to a null-terminated string specifying the name of a key that this function opens or creates. This key must be a subkey of the key identified by the hKey parameter. If hKey is one of the predefined keys, lpSubKey may be NULL. In that case, the handle returned by using phkResult is the same hKey handle passed in to the function. phkResultPoints to a variable that receives the handle of the opened or created key.  Return ValuesIf the function succeeds, the return value is ERROR_SUCCESS.
    If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.ResAn application can use the RegCreateKey function to create several keys at once. For example, an application can create a subkey four levels deep at the same time as the three preceding subkeys by specifying a string of the following form for the lpSubKey parameter: 
    subkey1\subkey2\subkey3\subkey4
    The key identified by the hKey parameter must have been opened with KEY_CREATE_SUB_KEY access (KEY_WRITE access includes KEY_CREATE_SUB_KEY access). If the lpSubKey parameter is the address of an empty string, the function opens and then passes back the key identified by the hKey parameter. 以上這些你可以在Help\Windows SDK中找到.
    有些偷懶,本來想翻譯一下的,太多了!
      

  3.   

    RegCreateKey(HKEY_LOCAL_MACHINE, 'Software\aaa', a);还是没有增加值,是不是要调用RegCloseKey呀