我有两个delphi的exe文件,分别为main.exe,base.exe
我现在要在main.exe中调用base.exe
调用方法如下:PathStr:=ExtractFilePath(Paramstr(0));
pathStr:=pathstr+'\'+'base.exe';
ShellExecute(0,nil.pchar(pathstr),nil,nil,SW_SHOW);当第一次调用时能打开base.exe,但当我关闭base.exe后再用main.exe打开就打不开了,没任何反映。
要重打开main.exe才行。不知什么原因,请各位帮忙。急啊。

解决方案 »

  1.   

    自已搞定了。可惜没人回答。
    现在改问一个简单的了怎么路径'c:\source\ba'返回成'c:\source'
    不能用切字符的办法。多搞定就结贴。
      

  2.   

    这是我写的通过文件名获取父目录的方法,给你参考一下function getparentdir(fielname:string):string;
    {获取父目录的函数}
    var
      s:string;
    begin
      result:='';
      if ExtractFilepath(filename)=ExtractFiledrv(filename) then
         showmessage('这是根目录,没有上层目录了')
      else
         begin
           s:=ExtractFiledir(filename);
           for i:=length(s) downto 1 do
               if s[i]='\' then
               begin
                  result:=copy(s,1,i);
                  break;
               end;     end;end;