如何通过可执行文件名获取进程句柄???????
请问在Delphi中有没有简单的办法通过可执行文件名获取正在运行的该可执行文件的进程的句柄(如果程序没有运行则返回null)? 问题点数:20、回复次数:4Top
1 楼jiaorg(jiaorg)回复于 2002-03-12 16:28:28 得分 15
这个你也许用得上
Q: How to execute a program and wait till it finishes (WIN 32).
A: function ProcessFG(const Filename, Arguments: String;
const WindowState: Word): Boolean;
var
StartUpInformation : TStartupInfo;
ProcessInformation : TProcessInformation;
CommandLine : String;
begin
// build command line
//
CommandLine := Filename + ' ' + Arguments;
// initialize start up information
//
FillChar(StartUpInformation, SizeOf(TStartUpInfo), Chr(0));
StartUpInformation.cb := SizeOf(TStartUpInfo);
StartUpInformation.dwFlags := STARTF_USESHOWWINDOW;
StartUpInformation.wShowWindow := WindowState;
// spawn process
//
Result := CreateProcess(nil, PChar(CommandLine),
nil, nil, FALSE,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
PChar(ExtractFilePath(Filename)), StartUpInformation,
ProcessInformation);
// wait for process to finish if created
//
if Result then WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
end;Top
2 楼xivan(人和妖都是妈生的)回复于 2002-03-12 16:31:22 得分 5
getmodulehandle(win32API函数)Top
3 楼goldenhua(Stay foolish. Stay hungry.)回复于 2002-03-12 16:48:47 得分 0
getmodulehandle 是没用的,我希望在另外一个程序中强制性的kill掉一个指定的程序(只知道可执行文件名)。Top
4 楼Kingron(单身走我路……)回复于 2002-03-12 16:56:19 得分 0
>>我希望在另外一个程序中强制性的kill掉一个指定的程序(只知道可执行文件名)
这个问题已经回答过了啊,搜索吧。Top




