// RegCreateKeyEx示例<br>procedure CreateKey(const RootKey : HKey; Key, ValueName, Value: string);<br>var<br> Handle: HKey;<br> Res,<br> Disposition: Integer;<br>begin<br> Res := RegCreateKeyEx(RootKey, PChar(Key), 0, '',<br> REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nil, Handle, @Disposition);<br> if Res = 0 then begin<br> Res := RegSetValueEx(Handle, PChar(ValueName), 0,<br> REG_SZ, PChar(Value), Length(Value) + 1);<br> RegCloseKey(Handle)<br> end;<br> if Res <> 0 then<br> raise Exception.Create('Error updating registry')<br>end;<br><br>//调用函数<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> CreateKey(HKEY_LOCAL_MACHINE,'Software/mytext','myown','1');<br>end;