现有
shuzu:  array of byte;
temp:string
 shuzu[0]:=...;
 shuzu[1]:=...;
 shuzu[2]:=...;
 shuzu[3]:=...;如何把shuzu转化为型string;
因为有
     WriteFile(hComm,PChar(temp)^,Length(shuzu),lrc,nil);
而我想用
     WriteFile(hComm,PChar(shuzu)^,Length(shuzu),lrc,nil);
这是 windows API 函数writeFile的定义;
     BOOL WriteFile(
           HANDLE hFile,
           LPCVOID LpBuffer,
           DWORD nNumerofofBytesToWrite,
           LPDWORD lpNumberofBytesWritten,
           LPOVERLAPPED lpoverlapped 
       )  

解决方案 »

  1.   

    var
      tmp : string;
      shuzu:  array[0..3] of byte;
      i : integer;
    begin
      shuzu[0]:=...;
      shuzu[1]:=...;
      shuzu[2]:=...;
      shuzu[3]:=...;
      setlegnth(tmp,legnth(shuzu));  For i:=0 to length(shuzu)-1 do
         tmp[i]:=inttostr(shuzu[i]);  WriteFile(hComm,PChar(shuzu)^,Length(shuzu),lrc,nil);
    End;行了。。
    byte 可以用inttostr直接搞成strings
    :)希望给全分并早点结贴。
    我测试通过的。
    :)
    over!!!
      

  2.   

    //直接写
    WriteFile(hComm,shuzu,SizeOf(shuzu),lrc,nil);
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
     var shuzu: array[0..9] of byte;
         i:integer;
    begin
    edit1.Text:='';
      shuzu[0]:=1;
      shuzu[1]:=2;
      shuzu[2]:=3;
      for i:=0 to 2 do
      edit1.Text:=edit1.Text+inttostr(shuzu[i]);
    end;
      

  4.   

    奇怪不行呀,我用的delphi 6,你呢?
      

  5.   

    For i:=0 to length(shuzu)-1 do
         tmp[i]:=inttostr(shuzu[i]);  WriteFile(hComm,PChar(shuzu)^,Length(shuzu),lrc,nil);
    End;//试了没成功WriteFile(hComm,shuzu,SizeOf(shuzu),lrc,nil);//ok  +100
      

  6.   

    For i:=0 to SizeOf(shuzu)-1 do
      tmp[i+1]:=inttostr(shuzu[i]);