{"id":1382,"date":"2024-08-13T08:00:00","date_gmt":"2024-08-13T00:00:00","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=1382"},"modified":"2024-07-19T10:28:27","modified_gmt":"2024-07-19T02:28:27","slug":"%e6%9e%9a%e4%b8%be%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=1382","title":{"rendered":"\u679a\u4e3e\u8fdb\u7a0b"},"content":{"rendered":"\n<p>&#8216;\u8c03\u7528\u793a\u4f8b<br>Dim I As Integer<br>Dim ShowArray As Variant<br>ShowArray = ProcessArray<br>For I = LBound(ShowArray) To UBound(ShowArray)<br>Debug.Print ShowArray(I)<br>Next I<\/p>\n\n\n\n<p>Option Explicit<br>Private Declare Function CreateToolhelp32Snapshot Lib &#8220;kernel32&#8221; (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long<br>Private Declare Function Process32First Lib &#8220;kernel32&#8221; (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long<br>Private Declare Function Process32Next Lib &#8220;kernel32&#8221; (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long<br>Private Declare Function CloseHandle Lib &#8220;kernel32&#8221; (ByVal hObject As Long) As Long<br>Private Declare Function OpenProcess Lib &#8220;kernel32&#8221; (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long<br>Private Declare Function TerminateProcess Lib &#8220;kernel32&#8221; (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long<\/p>\n\n\n\n<p>Private Type PROCESSENTRY32<br>dwSize As Long<br>cntUsage As Long<br>th32ProcessID As Long<br>th32DefaultHeapID As Long<br>th32ModuleID As Long<br>cntThreads As Long<br>th32ParentProcessID As Long<br>pcPriClassBase As Long<br>dwFlags As Long<br>szExeFile As String * 1024<br>End Type<\/p>\n\n\n\n<p>Const TH32CS_SNAPHEAPLIST = &amp;H1<br>Const TH32CS_SNAPPROCESS = &amp;H2<br>Const TH32CS_SNAPTHREAD = &amp;H4<br>Const TH32CS_SNAPMODULE = &amp;H8<br>Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)<br>Const TH32CS_INHERIT = &amp;H80000000<\/p>\n\n\n\n<p>Private Function ProcessArray() As Variant &#8216;\u751f\u6210\u8fdb\u7a0b\u540d\u6570\u7ec4<br>Dim pProcess As PROCESSENTRY32<br>Dim lRet As Long<br>Dim lRet1 As Long<br>Dim sName As String<br>Dim I As Integer<br>lRet = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)<br>If lRet Then<br>pProcess.dwSize = 1060<br>If (Process32First(lRet, pProcess)) Then &#8216;\u904d\u5386\u7b2c\u4e00\u4e2a\u8fdb\u7a0b<br>Dim iCount As Integer<br>Dim TempArray() As String<br>Do<br>I = InStr(1, pProcess.szExeFile, Chr(0))<br>sName = LCase(Left(pProcess.szExeFile, I &#8211; 1))<br>ReDim Preserve TempArray(0 To iCount)<br>TempArray(iCount) = sName<br>iCount = iCount + 1<br>Loop Until (Process32Next(lRet, pProcess) &lt; 1) &#8216;\u904d\u5386\u6240\u6709\u8fdb\u7a0b\u77e5\u9053\u8fd4\u56de\u503c\u4e3aFalse<br>End If<br>lRet1 = CloseHandle(lRet)<br>End If<br>ProcessArray = TempArray<br>End Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;\u8c03\u7528\u793a\u4f8bDim I As IntegerDim ShowArray As VariantShow &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=1382\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u679a\u4e3e\u8fdb\u7a0b\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-1382","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1382"}],"version-history":[{"count":1,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1382\/revisions"}],"predecessor-version":[{"id":1383,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1382\/revisions\/1383"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}