从ShellExecute怎么得到进程句柄,以及相关的窗口句柄?up有分!!!!

fanfyj 2003-11-11 12:29:36
在我的程序中有如下代码:
HINSTANCE Ret;

//开始切换服务
Ret = ShellExecute(m_hWnd,"open",StrApp1Path,"","",SW_SHOWNORMAL);

问题1:如何得到ShellExecute启动的应用程序的进程句柄?
问题2:怎么得到相关的窗口句柄?要求不用查找窗体标题的方法(这样没有普遍性),如FindWindow,EnumWindows等函数.最好直接能从进程得到与其相关的窗体句柄.
...全文
380 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
csccx555 2003-12-16
  • 打赏
  • 举报
回复
up
checkyvc6 2003-12-16
  • 打赏
  • 举报
回复
下面是我从msdn上拷过来的

If the function succeeds, it sets the hInstApp member of the SHELLEXECUTEINFO structure to the instance handle to the application that the function started. If the function fails, hInstApp is one of the SE_ERR_ error values indicating the cause of the failure. (An instance handle will always be greater than 32 and an error value less than 32.) Note that the SE_ERR_ error values are for compatibility with the ShellExecute function; use theGetLastError function to retrieve error information.

这好像可以得到,不过我建议各位还是用实践来证明一下

fishzlz 2003-12-15
  • 打赏
  • 举报
回复
gz

研究研究
fanfyj 2003-12-03
  • 打赏
  • 举报
回复
up
fanfyj 2003-11-25
  • 打赏
  • 举报
回复
up
fanfyj 2003-11-19
  • 打赏
  • 举报
回复
怎么没人来???


to:zhaolaoxin(), vcforever(霓裳羽衣)
hInstApp不是返回进程的句柄

hInstApp
If the function succeeds, it sets this member to a value greater than 32. If the function fails, it is set to an SE_ERR_XXX error value that indicates the cause of the failure. Although hInstApp is declared as an HINSTANCE for compatibility with 16-bit Windows applications, it is not a true HINSTANCE. It can be cast only to an integer and compared to either 32 or the following SE_ERR_XXX error codes.
linyd 2003-11-14
  • 打赏
  • 举报
回复
up
fanfyj 2003-11-14
  • 打赏
  • 举报
回复
up
akiko 2003-11-11
  • 打赏
  • 举报
回复
1.用CreateProcess,最后一个参数里包含了你要的句柄
2.FindWindow,再通过GetWindowThreadProcessId验证是否属于你刚才创建的进程
vcforever 2003-11-11
  • 打赏
  • 举报
回复
BOOL ShellExecuteEx(
LPSHELLEXECUTEINFO lpExecInfo
);


typedef struct _SHELLEXECUTEINFO{
DWORD cbSize;
ULONG fMask;
HWND hwnd;
LPCTSTR lpVerb;
LPCTSTR lpFile;
LPCTSTR lpParameters;
LPCTSTR lpDirectory;
int nShow;
HINSTANCE hInstApp;

// Optional members
LPVOID lpIDList;
LPCSTR lpClass;
HKEY hkeyClass;
DWORD dwHotKey;
union {
HANDLE hIcon;
HANDLE hMonitor;
};
HANDLE hProcess;
} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
sandy110 2003-11-11
  • 打赏
  • 举报
回复
学习...
zhaolaoxin 2003-11-11
  • 打赏
  • 举报
回复
BOOL ShellExecuteEx(
LPSHELLEXECUTEINFO lpExecInfo
);

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧