var
mysyspath:pchar;
mypath:pchar;
begin
getsystemdirectory(mysyspath,255);
391*****mypath:=mysyspath+'\System32\calc.exe';
shellexecute(application.MainForm.Handle,'open',pchar(mypath),nil,nil,sw_normal);
end;
[Error] Unit1.pas(391): Incompatible types: 'String' and 'PAnsiChar'

解决方案 »

  1.   

    mypath:=PChar(mysyspath+ '\System32\calc.exe');
      

  2.   

    var
    mysyspath:array[0..255] of char;
    mypath:string;
    begin
    getsystemdirectory(mysyspath,255);
    mypath:=mysyspath+'\calc.exe';
    shellexecute(application.MainForm.Handle,'open',pchar(mypath),nil,nil,sw_normal);
    end;
      

  3.   

    getsystemdirectory(mysyspath,255);已经包含了system32了,
    所以不用加system32\calc.exe,
    楼主,解决了没有?
      

  4.   

    Pchar类型和字符串类型是不能相加的。
    391*****mypath:=mysyspath+'\System32\calc.exe';
    应该是这样的:
      mypath:= PAnsiChar(StrPas(mysyspath) + '\System32\calc.exe');
      

  5.   

    //这是我的函数库的一个函数或许对你有帮助
    Function GetSystemDir: AnsiString;
    var
      lpStr: PAnsiChar;
      lpnLength:integer;
    begin
      Result:='';
      lpnLength:=GetSystemDirectory(nil,0); // 取得字串长度
      if lpnLength > 0 then
      begin
        GetMem(lpStr,lpnLength);
        if GetSystemDirectory(lpStr,lpnLength)>0 then
           Result := lpStr;
        FreeMem(lpStr,lpnLength);
      end;
    end;{ GetSystemDir}     //返回当前Windows系统System32目录的路径名(如:C:\Windows\System32)
    //下面是你要调用的这个函数代码var
      mypath:String;
    begin
       mypath:=GetSystemDir+'\calc.exe';
       shellexecute(application.MainForm.Handle,'open',pchar(mypath),nil,nil,sw_normal);
    end;