{"id":287,"date":"2009-06-12T23:32:36","date_gmt":"2009-06-12T18:02:36","guid":{"rendered":"http:\/\/techtwaddle.net\/?p=287"},"modified":"2011-04-12T23:32:51","modified_gmt":"2011-04-12T18:02:51","slug":"applications-process-viewer-update","status":"publish","type":"post","link":"https:\/\/techtwaddle.co.in\/blog\/2009\/06\/12\/applications-process-viewer-update\/","title":{"rendered":"Applications: Process Viewer update"},"content":{"rendered":"<div style=\"text-align: justify; font-family: Comic Sans MS;\">I noticed that I hadn&#8217;t added the filename associated with the process in the <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">Process Info<\/span> section <a href=\"http:\/\/geekswithblogs.net\/TechTwaddle\/archive\/2009\/05\/26\/applications-creating-a-simple-ui-application-from-scratch-process-viewer-again.aspx\">last time<\/a>. It struck me when looked at the PViewCE sample, which I mentioned about in this <a href=\"http:\/\/geekswithblogs.net\/TechTwaddle\/archive\/2009\/05\/31\/applications-pviewce-process-viewer-provided-with-sdk-samples.aspx\">post<\/a>.<\/p>\n<p>So I thought why not add the filename label, could anything else be simpler!<\/p>\n<p>I edited the dialog to include another static text control and added the code in <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">AllignComponents()<\/span> to beautify the control. But a small hiccup, when I ran the program just to test if it was displayed correctly, it wasn&#8217;t to be seen. And then I remembered that the group box hides it. Darn, not again! So I went back removed the group control, added the static text and then added the group control back on. The control displayed correctly. Use <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">GetModuleFileName()<\/span> api to get the filename associated with the process.<\/p>\n<p><span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">WINAPI DWORD GetModuleFileName(HMODULE hModule, LPWSTR lpFileName, DWORD nSize);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br \/>\nThe api takes the module handle for which the filename is requested, a buffer to hold the filename and finally the size of the buffer.<\/p>\n<p>For <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">hModule<\/span>, you can pass the <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">th32ProcessID <\/span>member of the <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">PROCESSENTRY32 <\/span>structure after casting it to <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">HMODULE<\/span>.<\/p>\n<p>Here is how I called the function in <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">ShowProcInfo()<\/span>:<\/p>\n<p><span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">TCHAR filename[256] = TEXT(&quot;Unknown&quot;);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">if(GetModuleFileName((HMODULE)pProcess-&gt;th32ProcessID, filename, sizeof(filename)\/sizeof(TCHAR)))<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">{..}<\/span><\/p>\n<p>Here are a few screen shots:<br \/>\n<img decoding=\"async\" loading=\"lazy\" width=\"352\" height=\"548\" src=\"\/images\/geekswithblogs_net\/TechTwaddle\/Process Viewer\/after_filename1.JPG\" alt=\"\" \/><\/p>\n<p>\n<img decoding=\"async\" loading=\"lazy\" width=\"353\" height=\"548\" src=\"\/images\/geekswithblogs_net\/TechTwaddle\/Process Viewer\/after_filename2.JPG\" alt=\"\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I noticed that I hadn&#8217;t added the filename associated with the process in the Process Info section last time. It struck me when looked at the PViewCE sample, which I mentioned about in this post. So I thought why not add the filename label, could anything else be simpler! I edited the dialog to include &hellip; <a href=\"https:\/\/techtwaddle.co.in\/blog\/2009\/06\/12\/applications-process-viewer-update\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Applications: Process Viewer update<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1ktFF-4D","_links":{"self":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/287"}],"collection":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":1,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/287\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}