我是这样写文件的FileWrite(hand,caption,Length(caption));
caption是widestring类型我有fileopen(hand,str,length(caption));//这里的caption是已经取出的数据大小但读出来全是乱码,为什么呀?怎么解决呢

解决方案 »

  1.   

    读:
    fileread(hand,caption[1],length(caption));
      

  2.   

    我试了一下,没用呀,谁能给个例程呀,就是要写入widesring类型的字符串到文件,然后再读出,本人是刚接触delphi,所以希望大家帮助啦。
      

  3.   

    procedure writefile(filename:string;s:string);
    var
    h:cardinal;
    begin
      h:=fileopen(filename,fmopenreadwrite);
      fileseek(h,0,0);
      filewrite(h,s[1],length(s));
      fileclose(h);
    end;
    function readfile(filename:string;len:cardinal):string;
    var
    h:cardinal;
    begin
      h:=fileopen(filename,fmopenread);
      fileseek(h,0,0);
      setlength(result,len);//关键是这个,先分配空间,然后才能读。
      fileread(h,result[1],len);
      fileclose(h);
    end;