var
    astr:pWidechar;
    rRegistry: TRegistry;
    MachineName: string;
begin
  MachineName='\\192.168.0.23';
  astr:=#$a7#$f8#$fc#$86#$73#$15#$b7#$ff;
  rRegistry:=TRegistry.Create;
  rRegistry.RootKey:=HKEY_LOCAL_Machine;
  if rRegistry.RegistryConnect(MachineName) then ShowMessage('OK');  //@1
  rRegistry.OpenKey('\software\ORL\WinVNC3',True);
  rRegistry.WriteBinaryData('Password',astr, 8);
  rRegistry.CloseKey;
  rRegistry.Free;
end;
当我正常运行后去查看‘192.168.0.23’的注册表时,发现‘Password’数据为 F0 71 47 00 CC 5A D0 00
当我将//@1处注释后,查本机的注册表时,发现'Password'数据为 A9 71 47 00 CC 5A D0 00
我的提问是为何会出现不同的结果?为何不是我想要的结果 a7 f8 fc 86 73 15 b7 ff

解决方案 »

  1.   

    试试这样
    buf : array[0..1024] of bytebuf[0]:=xxx
    buf[1]:=xxx
    ...//或者其他方式写入my_Reg.WriteBinaryData('Name', @Buf, Sizeof(buf))
      

  2.   

    >>我要的是指出我错的原因,多谢  astr:=#$a7#$f8#$fc#$86#$73#$15#$b7#$ff;
      showMessage(IntToStr(Length(astr)));
      

  3.   

    var
        astr: string;//pWidechar; //這裹
        rRegistry: TRegistry;
        MachineName: string;
    begin
      MachineName := '';// '\\192.168.0.23';  astr:=#$a7#$f8#$fc#$86#$73#$15#$b7#$ff;
    //  showMessage(IntToStr(Length(astr)));
      rRegistry:=TRegistry.Create;
      rRegistry.RootKey:=HKEY_LOCAL_Machine;
    //  if rRegistry.RegistryConnect(MachineName) then ShowMessage('OK');  //@1
      rRegistry.OpenKey('\software\Adobe\',True);
      rRegistry.WriteBinaryData('Password', (@astr[1])^, 8); //這裹
      rRegistry.CloseKey;
      rRegistry.Free;
    end;