Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to store settings in resource
    text
    copied!<p>i am trying to store some settings in resource of my application but failed i dont want to use ini file or registry methods i am using this code </p> <pre><code> var data :string; procedure WriteSettings(ServerFile: string; Settings: string); var ResourceHandle: THandle; pwServerFile: PWideChar; begin GetMem(pwServerFile, (Length(ServerFile) + 1) * 2); try StringToWideChar(ServerFile, pwServerFile, Length(ServerFile) * 2); ResourceHandle := BeginUpdateResourceW(pwServerFile, False); UpdateResourceW(ResourceHandle, MakeIntResourceW(10), 'SETTINGS', 0, @Settings[1], Length(Settings) + 1); EndUpdateResourceW(ResourceHandle, False); finally FreeMem(pwServerFile); end; end; function ReadSettings(ServerFile: string): string; var ServerModule: HMODULE; ResourceLocation: HRSRC; ResourceSize: dword; ResourceHandle: THandle; ResourcePointer: pointer; begin ServerModule := LoadLibrary(pchar(ServerFile)); try ResourceLocation := FindResource(ServerModule, 'SETTINGS', RT_RCDATA); ResourceSize := SizeofResource(ServerModule, ResourceLocation); ResourceHandle := LoadResource(ServerModule, ResourceLocation); ResourcePointer := LockResource(ResourceHandle); if ResourcePointer &lt;&gt; nil then begin SetLength(Result, ResourceSize - 1); CopyMemory(@Result[1], ResourcePointer, ResourceSize); FreeResource(ResourceHandle); end; finally FreeLibrary(ServerModule); end; end; procedure TForm1.saveClick(Sender: TObject); begin writesettings(paramastr(0),'true'); end; procedure TForm1.ReadClick(Sender: TObject); begin data:=readsettings(paramstr(0)); end; begin if data='true' then checkbox1.checked:=true; end </code></pre> <p>but is nit storing the that i wrote to resource :( is there any other better options? any help please </p>
 

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