哪位能给详细讲解一下STRPAS函数和PCHAR函数(1)strpas 是转换成shorstring  还是  ansistring

解决方案 »

  1.   


    StrPas源码 
    function StrPas(const Str: PChar): string;
    begin
      Result := Str;
    end;断点调试StrPas,反汇编:
    StrPas:
    00408E00 53               push ebx
    00408E01 56               push esi
    00408E02 8BF2             mov esi,edx
    00408E04 8BD8             mov ebx,eax
    00408E06 8BC6             mov eax,esi
    00408E08 8BD3             mov edx,ebx
    00408E0A E8FDBBFFFF       call @LStrFromPChar//System单元的函数
    00408E0F 5E               pop esi
    00408E10 5B               pop ebx
    00408E11 C3               ret 关于PChar:
    PChar是指向以0结尾的字符串的指针,不是函数。像函数一样使用它的时候,实际上是类型的强制转换(但编译器也生成了相关的函数调用代码)。
    比如调试语句StrPas(PChar(S)):
    Unit1.pas.30: StrPas(PChar(S))
    004552E6 8B45FC           mov eax,[ebp-$04]
    004552E9 E8B6F9FAFF       call @LStrToPChar//此句对应于PChar(S),LStrToPChar也是System单元的函数
    004552EE 8D55F8           lea edx,[ebp-$08]
    004552F1 E80A3BFBFF       call StrPas
      

  2.   


    我用的是DELPHI7    DELPHI7中 StrPas是转成  shorstring 还是 ansistring