faint
you should know the windows have some different classes, for example
TForm, TRankForm..... you can also register your class...
so just try enumwindow , if you need example , tell me.
about you question, you can use shellexecute in the place of Winexec
shellexecute will return a Hinstance, if less than 32 means you have
already run this program.
cAkk,
你的方法不錯,當我判斷外部程序在開啟後,把它開啟至桌面,我用的是
下面的方法.但我不知怎樣得到每个process对应的classname,請指教.
if SetForegroundWindow(findwindow(classname,nil)) then
SendMessage(Findwindow(classname,nil),wm_syscommand,SC_RESTORE,0)
你怎么枚举进程的? 为什么要得到classname? 你只要知道exe文件名就可以了:
var
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
Ret : BOOL;
lst:tstringlist;
begin
lst:=tstringlist.create;
FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
Ret:=Process32First(FSnapshotHandle,FProcessEntry32);
while Retdo
begin
lst.add(FProcessEntry32.szExeFile);
//这就是exe文件名
Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);