在aaa.exe中加入GetCurrentDirectory得到他的路径。

解决方案 »

  1.   


    这里有一个例子列出找出所有进程信息的方法
    你可以用来试试,相信你能解决的!
    const
    ProcessInfoCaptions: array[0..3] of string = (
     'ProcessName', 'Threads', 'ID', 'ParentID');
    procedure TFormServer.FillProcessInfoList();
    var
      I: Integer;
      ExeFile: string;
      PE: TProcessEntry32;
      HAppIcon: HIcon;
    begin
      Refresh;
      ListView.Columns.Clear;
      ListView.Items.Clear;
      for I := Low(ProcessInfoCaptions) to High(ProcessInfoCaptions) do
        with ListView.Columns.Add do
        begin
          if I = 0 then Width := 285
          else Width := 75;
          Caption := ProcessInfoCaptions[I];
        end;
      for I := 0 to FProcList.Count - 1 do
      begin
        PE := PProcessEntry32(FProcList.Items[I])^;
        HAppIcon := ExtractIcon(HInstance, PE.szExeFile, 0);
        try
          if HAppIcon = 0 then HAppIcon := FWinIcon;
          ExeFile := PE.szExeFile;
          if ListView.ViewStyle = vsList then
            ExeFile := ExtractFileName(ExeFile);
          // insert new item, set its caption, add subitems
          with ListView.Items.Add, SubItems do
          begin
            Caption := ExeFile;
            Data := FProcList.Items[I];
            Add(IntToStr(PE.cntThreads));
            Add(IntToHex(PE.th32ProcessID, 8));
            Add(IntToHex(PE.th32ParentProcessID, 8));
           // if ImageList <> nil then
            //  ImageIndex := ImageList_AddIcon(ImageList.Handle, HAppIcon);
          end;
        finally
          if HAppIcon <> FWinIcon then DestroyIcon(HAppIcon);
        end;
      end;
    end;
      

  2.   

    getModelfile函数不知道拼写对不对!
      

  3.   

    应该是GetModuleFileName,它可以得到!
      

  4.   

    首先用loadLibary载入aa.exe
    GetModuleFileName的第一个参数是loadLibary的返回值第2个参数返回程序的路径,第三个是路径的长度!
      

  5.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        procedure FormShow(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormShow(Sender: TObject);
    begin
    application.MainForm.Caption:=application.ExeName ;
    application.Title:='你好';
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    showmessage(extractfilename(application.exename));
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
     showmessage(extractfilepath(application.exename));
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
    showmessage(extractfileext(application.exename));
    end;end.