Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#10

Re: Registry ReadBinaryData Problem

  Alt 10. Aug 2008, 22:30
Hallo, du musst die #0 noch entfernen

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
const
  CDataValue: string = 'ItemPos1280x1024(1)';
  CKeyName: string = 'Software\Microsoft\Windows\Shell\Bags\1\Desktop';
var
  regist: TRegistry;
  KeyExists: boolean;
  vSize, p: integer;
  tmpStr: string;
begin
  regist := TRegistry.Create;
  try
    regist.RootKey := HKEY_CURRENT_USER;
    try
      KeyExists := regist.OpenKey(CKeyName, false);
      if (KeyExists) then
      begin
        vSize := regist.GetDataSize(CDataValue);
        if (vSize > 0) then
        begin
          SetLength(tmpStr, vSize);
          regist.ReadBinaryData(CDataValue, tmpstr[1], vSize);
          repeat
            p := Pos(#0, tmpStr);
            if p <> 0 then
              Delete(tmpStr, p, 1);
          until p = 0;
          Memo1.Text := tmpStr;
        end;
      end;
    except
      regist.CloseKey;
    end
  finally
    regist.Free;
  end;
end;
Thomas
  Mit Zitat antworten Zitat