procedure WriteBinaryData(const Name: string; var Buffer; BufSize: Integer);
WriteBinaryData('HistPaths',buf,0); function StrToMyHex( const S: string ): string ; var i: Integer ; len: Integer ; begin len:=Length(S); if len> 0 then begin Result:=Format( 'hex:%s,00' ,[IntToHex(Ord(S[ 1 ]), 2 )]); for i:= 2 to len do begin Result:=Format( '%s,%s,00' ,[Result,IntToHex(Ord(S[i]), 2 )]); end ; Result:=Result+ ',00,00' ; end else Result:= '' ; end ;
uses Registry; procedure TForm2 . FormCreate(Sender: TObject); var i,len: integer ; Buf: array of byte ; R:TRegistry; Str: WideString ; begin Str := 'pop.126.com' ; len:=length(Str); SetLength(Buf,(len+ 1 )*sizeof( WideChar )); fillchar( Buf[ 0 ],Length(buf), 0 ); // for i:=0 to len-1 do // begin // Buf[i]:=ord(Str[i+1]); // end; Move( Byte (Str[ 1 ]),Buf[ 0 ],len*sizeof( WideChar )); R:=TRegistry . Create; Try R . RootKey := HKEY_CURRENT_USER; if R . OpenKey( 'Software\test' , True ) then try R . WriteBinaryData( 'Display Name' ,Buf[ 0 ],Length(Buf)); finally R . CloseKey; end ; Finally R . Free; End ; end ; |