function PathRemoveSeparator(const Path: string): string;<br>var<br> L: Integer;<br>begin<br> L := Length(Path);<br> if (L <> 0) and (AnsiLastChar(Path) = PathSeparator) then<br> Result := Copy(Path, 1, L - 1)<br> else<br> Result := Path;<br>end;<br><br>procedure StrResetLength(var S: AnsiString);<br>begin<br> SetLength(S, StrLen(PChar(S)));<br>end;<br><br>function GetWindowsTempFolder: string;<br>var<br> Required: Cardinal;<br>begin<br> Result := '';<br> Required := GetTempPath(0, nil);<br> if Required <> 0 then<br> begin<br> SetLength(Result, Required);<br> GetTempPath(Required, PChar(Result));<br> StrResetLength(Result);<br> Result := PathRemoveSeparator(Result);<br> end;<br>end;<br><br>function RelativeKey(const Key: string): PChar;<br>begin<br> Result := PChar(Key);<br> if (Key <> '') and (Key[1] = '/') then<br> Inc(Result);<br>end;<br><br> <br>function RegReadStringDef(const RootKey: HKEY; const Key, Name, Def: string): string;<br>var<br> RegKey: HKEY;<br> Size: DWORD;<br> StrVal: string;<br> RegKind: DWORD;<br>begin<br> Result := Def;<br> if RegOpenKeyEx(RootKey, RelativeKey(Key), 0, KEY_READ, RegKey) = ERROR_SUCCESS then<br> begin<br> RegKind := 0;<br> Size := 0;<br> if RegQueryValueEx(RegKey, PChar(Name), nil, @RegKind, nil, @Size) = ERROR_SUCCESS then<br> if RegKind in [REG_SZ, REG_EXPAND_SZ] then<br> begin<br> SetLength(StrVal, Size);<br> if RegQueryValueEx(RegKey, PChar(Name), nil, @RegKind, PByte(StrVal), @Size) = ERROR_SUCCESS then<br> begin<br> SetLength(StrVal, StrLen(PChar(StrVal)));<br> Result := StrVal;<br> end;<br> end;<br> RegCloseKey(RegKey);<br> end;<br>end;