{"id":13033,"date":"2010-08-26T07:00:00","date_gmt":"2010-08-26T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/08\/26\/how-do-i-recover-the-window-handle-passed-to-shellexecute\/"},"modified":"2010-08-26T07:00:00","modified_gmt":"2010-08-26T07:00:00","slug":"how-do-i-recover-the-window-handle-passed-to-shellexecute","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100826-00\/?p=13033","title":{"rendered":"How do I recover the window handle passed to ShellExecute?"},"content":{"rendered":"<p>A customer had the following question:<\/p>\n<blockquote class=\"q\"><p> I&#8217;m using the <code>ShellExecute<\/code> function to launch a new process and am passing the handle to my application&#8217;s main window as the <code>hwnd<\/code> parameter. From the new process, I want to get information from the old process, and to do that, I need the window handle. How can I recover that window handle from the new process? <\/p><\/blockquote>\n<p> You can&#8217;t.\n That window handle is used by the <code>ShellExecute<\/code> function only to host any user interface operations that occur as a result of the attempt to execute the program. For example, it is the owner window used for any error dialogs. The <code>ShellExecute<\/code> function does not pass the window handle to the launched process. (It couldn&#8217;t even if it wanted to: There is nowhere to pass it. There is no window handle among the parameters to <code>CreateProcess<\/code> nor is there a window handle in the <code>STARTUPINFO<\/code> structure.)<\/p>\n<p> If you want to pass this information to the process being launched, you&#8217;ll have to come up with your own mechanism for transferring this information. For example, you can pass it <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/12\/10\/56028.aspx\"> on the command line<\/a>, or if you have a lot of information to pass, you can <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/12\/11\/56043.aspx\"> use a shared memory block<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer had the following question: I&#8217;m using the ShellExecute function to launch a new process and am passing the handle to my application&#8217;s main window as the hwnd parameter. From the new process, I want to get information from the old process, and to do that, I need the window handle. How can I [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-13033","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A customer had the following question: I&#8217;m using the ShellExecute function to launch a new process and am passing the handle to my application&#8217;s main window as the hwnd parameter. From the new process, I want to get information from the old process, and to do that, I need the window handle. How can I [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=13033"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13033\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=13033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=13033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=13033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}