Note that there are some explanatory texts on larger screens.

plurals
  1. POError when trying to save value in registry
    text
    copied!<p>Using the code below I try to set a value in the HKEY_LOCAL_MACHINE section of registry but I get an error 'Failed to set data for.....' If I use HKEY_CURRENT_USER there is no problem.</p> <p>What might I be missing here.</p> <p>(The code is not complete, but I think it is the important parts of it)</p> <pre><code>type TTypWinBits = (Bit32, Bit64); function WinBits: TTypWinBits; type TIsWow64Process = function(Handle:THandle; var IsWow64 : BOOL) : BOOL; stdcall; var hKernel32 : Integer; IsWow64Process : TIsWow64Process; IsWow64 : BOOL; begin Result := Bit32; hKernel32 := LoadLibrary('kernel32.dll'); if (hKernel32 = 0) then RaiseLastOSError; @IsWow64Process := GetProcAddress(hkernel32, 'IsWow64Process'); if Assigned(IsWow64Process) then begin IsWow64 := False; if (IsWow64Process(GetCurrentProcess, IsWow64)) then Result := Bit64 else RaiseLastOSError; end; FreeLibrary(hKernel32); end; function TFastRegistry.CreateConnection: TRegistry; begin Result := TRegistry.Create; try case WinBits of Bit32: Result := TRegistry.Create; Bit64: Result := TRegistry.Create(KEY_WRITE OR KEY_WOW64_64KEY); end; except on E: exception do Result := nil; end; end; procedure TFastRegistry.RunAdd(aDesc, aName: string); var Reg: TRegistry; sRegKey: String; begin sRegKey := 'Software\Microsoft\Windows\CurrentVersion\Run'; Reg := CreateConnection; with Reg do begin try RootKey := HKEY_LOCAL_MACHINE; if not KeyExists(sRegKey) then OpenKey(sRegKey, True) else OpenKey(sRegKey, False); WriteString(aDesc, aName); finally CloseKey; Free; end; end; end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload