我用的是获取系统进程快照 ,感觉这样很占内存呀

解决方案 »

  1.   

    知道路径,可以用rename或者deletefile,不成功就表示正在用
    否则就遍历进程了
      

  2.   

    我是通过进程快照 得到了QQ的exe路径
    谢谢大家
      

  3.   

    检测 进程是否有qq.exe 即可
      

  4.   

    参考这个,由于一些东西,不多讲.
    http://www.hack50.com/qq/181/75188.html
      

  5.   

    DELPHI版本的
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, TLHelp32, PsApi;
    -----------------------------------------------------------------------------
    function GetProcessPath(ProcessID: DWORD): string;
    var
            mHandle: THandle;
            ModName: Array[0..Max_Path-1] of Char;
            hMod: HModule;
            n: DWORD;
    begin
            Result:='';        mHandle:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,
                    False,
                    ProcessID);
            if mHandle>0 then
                    try
                            //uses PsAPI
                            ENumProcessModules(mHandle,@hMod,Sizeof(hMod),n);
                            if GetModuleFileNameEx(mHandle,hMod,ModName,Sizeof(ModName))>0 then
                                    Result:=ModName;
                    except
                    end;
    end;
      

  6.   

    function GetPath(AFileName: string): string;
    const
            PROCESS_TERMINATE = $0001;
    var
            ContinueLoop: BOOL;
            FSnapShotHandle: THandle;
            FProcessEntry32: TProcessEntry32;
    begin
            //uses TLHelp32
            result := '';
            FSnapShotHandle := CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS, 0);
            FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
            ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
            while integer(ContinueLoop) <> 0 do
            begin
                    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(AFileName))
                            or (UpperCase(FProcessEntry32.szExeFile ) = UpperCase(AFileName))) then
                    begin
                            result := GetProcessPath(FProcessEntry32.th32ProcessID);
                            break;
                    end;
                    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
            end;
    end;---------------------------------
    引用方式
     showmessage(GetPath('qq.exe'));结帖子给分吧
      

  7.   

    function GetPath(AFileName: string): string;
    const
            PROCESS_TERMINATE = $0001;
    var
            ContinueLoop: BOOL;
            FSnapShotHandle: THandle;
            FProcessEntry32: TProcessEntry32;
    begin
            //uses TLHelp32
            result := '';
            FSnapShotHandle := CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS, 0);
            FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
            ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
            while integer(ContinueLoop) <> 0 do
            begin
                    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(AFileName))
                            or (UpperCase(FProcessEntry32.szExeFile ) = UpperCase(AFileName))) then
                    begin
                            result := GetProcessPath(FProcessEntry32.th32ProcessID);
                            break;
                    end;
                    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
            end;
    end;---------------------------------
    引用方式
     showmessage(GetPath('qq.exe'));结帖子给分吧