how to close the file that is opened by shellexecute function?(50分)

  • 主题发起人 主题发起人 garden_wood
  • 开始时间 开始时间
G

garden_wood

Unregistered / Unconfirmed
GUEST, unregistred user!
I think the reply to this question exsiting in the BBS, but i can't type in chinese ,so i can't search it.
a file,eg.A.bmp,i use the API ShellExecute function to open it.
then, i want to close the Program ACDSee,after it already run.
so i use sendmessage.
but,the problem is i can't get the handle of the runing program!
the value Shellexecute returning is only instance handle,not handle.so i can't use it in sendmessage!
how can i do?

BTW: i can't use the chinese,for my PC System is Linux,and i don't install GCE. //hehe
 
用 FindWindow 找该窗口(通过窗口标题或者窗口类)
然后 PostMessage WM__CLOSE

或者 GetWindowThreadProcessId 得到进程id,然后OpenProcess, 然后TerminateProcess
 
sorry. your method can't run!
first, the Caption of the Programe can't got.for example: shellexecute a file named A.txt, the system open it use NotePad.
so The caption is "A.txt-NotePad",and so on.so i can't make sure what
caption for the file i want to open.
second,GetWindowsProcessID acqure a value for windows handle.but the value shellexecute function returns is instance handle,not windows handle.
so i can't use the GetWindowsProcessID.
en.....at last, i find a method to solve it.
i use findexecutable function to got the exectable program name for the file unexectable (eg. a.txt...).
and use createPorcess create a process .then i got the Process ID,so
I can Terminate it!
//hehe but i find a strang question:
some file such as a.cpp,can't open bye createprocess,shellexecute or winexec..the return value is 31,it means there is no application assocate with given filnane.
//faint but i can double click the icon for the a.cpp, the system can open it with VC.
why?
 
接受答案了.
 

Similar threads

A
回复
0
查看
943
Andreas Hausladen
A
A
回复
0
查看
993
Andreas Hausladen
A
A
回复
0
查看
819
Andreas Hausladen
A
A
回复
0
查看
974
Andreas Hausladen
A
后退
顶部