{"id":126367,"date":"2024-03-24T22:11:22","date_gmt":"2024-03-24T13:11:22","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/"},"modified":"2024-03-26T18:07:15","modified_gmt":"2024-03-26T09:07:15","slug":"shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/","title":{"rendered":"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b"},"content":{"rendered":"<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092ShellExecute\u95a2\u6570\u3067\u8d77\u52d5\u3057\u305f\u3089\u3001\u305d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306eProcess ID (PID) \u3092ShellExecuteEx\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306b\u3001ShellExecuteEx \u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066 PID \u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-meta\">#<span class=\"hljs-keyword\">include<\/span> <span class=\"hljs-string\">&lt;windows.h&gt;<\/span><\/span>\r\n<span class=\"hljs-meta\">#<span class=\"hljs-keyword\">include<\/span> <span class=\"hljs-string\">&lt;iostream&gt;<\/span><\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-type\">int<\/span> <span class=\"hljs-title\">main<\/span><span class=\"hljs-params\">()<\/span>\r\n<\/span>{\r\n<span class=\"hljs-comment\">\/\/ \u5b9a\u4e49\u5e76\u521d\u59cb\u5316SHELLEXECUTEINFO\u7ed3\u6784\u4f53<\/span>\r\nSHELLEXECUTEINFO sei = {<span class=\"hljs-number\">0<\/span>};\r\nsei.cbSize = <span class=\"hljs-built_in\">sizeof<\/span>(SHELLEXECUTEINFO);\r\nsei.fMask = SEE_MASK_NOCLOSEPROCESS;  <span class=\"hljs-comment\">\/\/ \u8bbe\u7f6e\u8be5\u6807\u5fd7\u4f4d\u4ee5\u83b7\u53d6\u8fdb\u7a0b\u53e5\u67c4<\/span>\r\nsei.lpFile = <span class=\"hljs-built_in\">TEXT<\/span>(<span class=\"hljs-string\">\"C:\\\\path\\\\to\\\\your\\\\application.exe\"<\/span>);  <span class=\"hljs-comment\">\/\/ \u8981\u6253\u5f00\u7684\u5e94\u7528\u7a0b\u5e8f\u8def\u5f84<\/span>\r\n<span class=\"hljs-comment\">\/\/ \u4f7f\u7528ShellExecuteEx\u51fd\u6570\u6253\u5f00\u5e94\u7528\u7a0b\u5e8f<\/span>\r\n<span class=\"hljs-keyword\">if<\/span> (<span class=\"hljs-built_in\">ShellExecuteEx<\/span>(&amp;sei))\r\n{\r\n<span class=\"hljs-comment\">\/\/ \u83b7\u53d6\u8fdb\u7a0bID<\/span>\r\nDWORD pid = <span class=\"hljs-built_in\">GetProcessId<\/span>(sei.hProcess);\r\n<span class=\"hljs-comment\">\/\/ \u8f93\u51fa\u8fdb\u7a0bID<\/span>\r\nstd::cout &lt;&lt; <span class=\"hljs-string\">\"Process ID: \"<\/span> &lt;&lt; pid &lt;&lt; std::endl;\r\n<span class=\"hljs-comment\">\/\/ \u5173\u95ed\u8fdb\u7a0b\u53e5\u67c4<\/span>\r\n<span class=\"hljs-built_in\">CloseHandle<\/span>(sei.hProcess);\r\n}\r\n<span class=\"hljs-keyword\">else<\/span>\r\n{\r\n<span class=\"hljs-comment\">\/\/ \u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u5931\u8d25<\/span>\r\nstd::cout &lt;&lt; <span class=\"hljs-string\">\"Failed to open application.\"<\/span> &lt;&lt; std::endl;\r\n}\r\n<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-number\">0<\/span>;\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u3067\u306fShellExecuteEx\u95a2\u6570\u3092\u7528\u3044\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u304d\u3001SEE_MASK_NOCLOSEPROCESS\u30d5\u30e9\u30b0\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u30d7\u30ed\u30bb\u30b9\u30cf\u30f3\u30c9\u30eb\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001GetProcessId\u95a2\u6570\u3067\u30d7\u30ed\u30bb\u30b9ID\u3092\u53d6\u5f97\u3057\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001CloseHandle\u95a2\u6570\u3067\u30d7\u30ed\u30bb\u30b9\u30cf\u30f3\u30c9\u30eb\u3092\u9589\u3058\u307e\u3059\u3002<\/p>\n<p>\u5c1a\u3001ShellExecuteEx\u95a2\u6570\u306f\u3001\u30a2\u30d7\u30ea\u3060\u3051\u3067\u306a\u304f\u3001\u3042\u3089\u3086\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u306e\u7a2e\u985e\u306f\u3001sei.lpFile\u306b\u958b\u304f\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u30d1\u30b9\u3092\u8a2d\u5b9a\u3059\u308b\u3060\u3051\u3067\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092ShellExecute\u95a2\u6570\u3067\u8d77\u52d5\u3057\u305f\u3089\u3001\u305d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306eProcess ID (PID) \u3092ShellExecuteEx\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 \u4ee5\u4e0b\u306b\u3001ShellExecuteEx \u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066 [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-126367","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-\u304b\u3089-pid-\u3092\u53d6\u5f97\u3059\u308b\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b\" \/>\n<meta property=\"og:description\" content=\"\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092ShellExecute\u95a2\u6570\u3067\u8d77\u52d5\u3057\u305f\u3089\u3001\u305d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306eProcess ID (PID) \u3092ShellExecuteEx\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 \u4ee5\u4e0b\u306b\u3001ShellExecuteEx \u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-\u304b\u3089-pid-\u3092\u53d6\u5f97\u3059\u308b\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-24T13:11:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-26T09:07:15+00:00\" \/>\n<meta name=\"author\" content=\"\u512a\u6597, \u671d\u967d\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u512a\u6597, \u671d\u967d\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/\",\"name\":\"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2024-03-24T13:11:22+00:00\",\"dateModified\":\"2024-03-26T09:07:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cab7534c71201607a41f395de14d7d28\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cab7534c71201607a41f395de14d7d28\",\"name\":\"\u512a\u6597, \u671d\u967d\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/56ecb1d20648a2ff67709eeaa7b6eddeb4d52aca0d46febc7f12bbef507187d0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/56ecb1d20648a2ff67709eeaa7b6eddeb4d52aca0d46febc7f12bbef507187d0?s=96&d=mm&r=g\",\"caption\":\"\u512a\u6597, \u671d\u967d\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/yutoasahi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-\u304b\u3089-pid-\u3092\u53d6\u5f97\u3059\u308b\/","og_locale":"ja_JP","og_type":"article","og_title":"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b","og_description":"\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092ShellExecute\u95a2\u6570\u3067\u8d77\u52d5\u3057\u305f\u3089\u3001\u305d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306eProcess ID (PID) \u3092ShellExecuteEx\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 \u4ee5\u4e0b\u306b\u3001ShellExecuteEx \u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-\u304b\u3089-pid-\u3092\u53d6\u5f97\u3059\u308b\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-24T13:11:22+00:00","article_modified_time":"2024-03-26T09:07:15+00:00","author":"\u512a\u6597, \u671d\u967d","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u512a\u6597, \u671d\u967d"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/","name":"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2024-03-24T13:11:22+00:00","dateModified":"2024-03-26T09:07:15+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cab7534c71201607a41f395de14d7d28"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"ShellExecute \u304b\u3089 PID \u3092\u53d6\u5f97\u3059\u308b"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cab7534c71201607a41f395de14d7d28","name":"\u512a\u6597, \u671d\u967d","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/56ecb1d20648a2ff67709eeaa7b6eddeb4d52aca0d46febc7f12bbef507187d0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/56ecb1d20648a2ff67709eeaa7b6eddeb4d52aca0d46febc7f12bbef507187d0?s=96&d=mm&r=g","caption":"\u512a\u6597, \u671d\u967d"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/yutoasahi\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/shellexecute-%e3%81%8b%e3%82%89-pid-%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/126367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=126367"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/126367\/revisions"}],"predecessor-version":[{"id":144073,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/126367\/revisions\/144073"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=126367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=126367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=126367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}