{"id":3240,"date":"2015-12-11T09:44:54","date_gmt":"2015-12-11T01:44:54","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=3240"},"modified":"2015-12-11T09:52:28","modified_gmt":"2015-12-11T01:52:28","slug":"%e6%95%99%e7%a8%8b-%e8%8e%b7%e5%8f%96%e5%bd%93%e5%89%8d%e8%bf%9b%e7%a8%8b%e7%9a%84%e7%88%b6%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=3240","title":{"rendered":"[\u6559\u7a0b] \u83b7\u53d6\u5f53\u524d\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b"},"content":{"rendered":"<p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u6211\u4eec\u9700\u8981\u77e5\u9053\u81ea\u5df1\u6240\u96b6\u5c5e\u7684\u7236\u8fdb\u7a0b\u7684ID\u3002\u6709\u51e0\u4e2a\u529e\u6cd5\uff0c\u4e00\u4e2a\u662f\u8c03\u7528\u5fae\u8f6f\u672a\u516c\u5f00\u7684\u00a0NtQueryInformationProcess \u51fd\u6570\uff0c\u53e6\u4e00\u4e2a\u5c31\u662f\u4e0b\u9762\u63d0\u4f9b\u7684\u4e00\u4e2a\u51fd\u6570\uff0c\u5229\u7528\u4e86\u516c\u5f00\u7684\u51fd\u6570\uff0c\u8fd0\u884c\u9700\u8981\u5305\u542b tlhelp32 \u5355\u5143\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">function GetParentProcessId: Cardinal;\r\n  var\r\n    hSnapshot: THandle;\r\n    AEntry: TProcessEntry32;\r\n  begin\r\n    Result := 0;\r\n    hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);\r\n    if hSnapshot &lt;&gt; INVALID_HANDLE_VALUE then\r\n    begin\r\n      try\r\n        AEntry.dwSize := sizeof(TProcessEntry32);\r\n        if Process32First(hSnapshot, AEntry) then\r\n        begin\r\n          repeat\r\n            if AEntry.th32ProcessID = GetCurrentProcessId then\r\n            begin\r\n              Result := AEntry.th32ParentProcessID;\r\n              break;\r\n            end;\r\n          until not Process32Next(hSnapshot, AEntry);\r\n        end;\r\n      finally\r\n        CloseHandle(hSnapshot);\r\n      end;\r\n    end;\r\n  end;<\/pre>\n<p>\u8fd9\u4e2a\u51fd\u6570\u76f4\u63a5\u4f1a\u8fd4\u56de\u5f53\u524d\u7684\u7236\u8fdb\u7a0b\u7684ID\uff0c\u5982\u679c\u627e\u4e0d\u5230\uff0c\u8fd4\u56de0.<\/p>\n<p>\u5f53\u7136\uff0c\u6839\u636e\u4e0a\u9762\u7684\u539f\u56e0\uff0c\u4f60\u5f88\u5bb9\u6613\u5c31\u53ef\u4ee5\u5199\u51fa\u679a\u4e3e\u6240\u6709\u5b50\u8fdb\u7a0b\u7684\u51fd\u6570\u4e86\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u7f00\u8ff0\u4e86\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u60f3\u6cd5\u5199\u5199\u770b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u6211\u4eec\u9700\u8981\u77e5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8,21],"tags":[503,502,158],"class_list":["post-3240","post","type-post","status-publish","format-standard","hentry","category-delphi","category-misc","tag-id","tag-502","tag-158"],"views":6235,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3240"}],"version-history":[{"count":3,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3240\/revisions"}],"predecessor-version":[{"id":3243,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3240\/revisions\/3243"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}