logo

Python Win32 프로세스

이 기사에서는 Python win32 프로세스에 대해 설명합니다. 그리고 그 방법도 하나씩 논의해 보겠습니다.

기본적으로 Win32 프로세스는 Python의 메서드입니다. 이 모듈을 통해 확장된 Win32 프로세스 생성 및 관리 기능에 액세스할 수 있습니다. Create 메소드는 프로세스 객체(생성자)를 생성합니다. 추가 방법을 사용하여 객체에 대한 프로세스의 종료, 일시 중지, 재개 및 우선 순위 설정이 가능합니다.

WMI(이전의 WBEM) 및 Windows 드라이버 모델용 WMI 확장은 Windows 2019/2016/2012/2008 및 Windows 10/7/XP(WDM)의 관리 효율성을 위한 기반 역할을 합니다.

WMI를 기반으로 모니터 확인 절차를 생성하는 기능은 ActiveXperts Network Monitor에서 제공됩니다. ActiveXperts가 수집한 WMI 샘플은 100개가 넘습니다. 이러한 예는 여러분이 스스로 생성하는 새로운 점검 루틴의 출발점이 될 수 있습니다.

이 웹 사이트에서는 다양한 WMI 샘플을 사용할 수 있습니다.

ActiveXperts 네트워크 모니터는 Win32_Process WMI 클래스를 사용하여 서버를 모니터링합니다.

Windows 운영 체제의 일련의 이벤트는 Win32_Process WMI 클래스로 표시됩니다. 하나 이상의 프로세서 또는 인터프리터, 일부 실행 코드 및 입력 집합(예: Windows 시스템에서 실행되는 클라이언트 프로그램)의 상호 작용을 포함하는 시퀀스는 이 클래스의 하위 항목이거나 멤버입니다.

이제 질문이 생깁니다 파이썬 win32란 무엇입니까?

따라서 Python win32 및 Win32 API(응용 프로그래밍 인터페이스) 기능은 Windows용 PyWin32 확장 라이브러리를 사용하여 Python과 함께 사용할 수 있습니다.

에 대한 간단한 소개를 해보자. win32api 모듈.

win32api 모듈은 프로세스 제어를 위한 다양한 추가 방법을 제공합니다. 이를 통해 새로운 프로세스를 시작하는 데 필요한 많은 일반적인 단계를 수행할 수 있지만 여전히 최고 수준의 낮은 수준 제어를 제공하기에는 부족합니다.

앞서 설명한 os.system 함수와 달리 WinExec 함수는 GUI 프로그램에 다양한 편의를 제공합니다. 예를 들어 콘솔이 설정되지 않고 함수는 새 프로세스가 완료될 때까지 기다리지 않습니다.

이 함수에는 다음 두 가지 입력이 필요합니다.

  • 수행하라는 명령
  • 또는 응용 프로그램 창의 초기 상태

에 대한 간단한 소개를 해보자. win32api.ShellExecute.

또한 win32api 모듈은 새 프로세스를 시작하는 데 유용한 또 다른 기능을 제공합니다. 임의 프로세스를 시작하는 것과 달리 문서를 여는 것이 ShellExecute 함수의 주요 목적입니다. 예를 들어 ShellExecute에 'MyDocument.doc 열기'를 지시할 수 있습니다. Windows는 .doc 파일을 열기 위해 사용자를 대신하여 시작할 프로세스를 선택합니다. a.doc 파일을 클릭(또는 두 번 클릭)하면 Windows 탐색기가 동일한 작업을 수행합니다.

실행 중인 프로그램을 프로세스(처리됨)라고 합니다. 프로세스는 사용자가 수동으로 실행하는 프로세스일 필요는 없습니다. 대신 운영 체제가 생성하는 시스템 프로세스일 수 있습니다. 운영 체제에서 실행되는 모든 프로그램은 작동을 시작하기 전에 먼저 별도의 프로세스를 생성해야 합니다. 일반적인 OS 설치 프로세스의 대부분은 하드웨어, 소프트웨어 및 운영 체제를 양호한 작동 순서로 유지하는 데 사용되는 백그라운드 프로그램 및 운영 체제 서비스입니다.

이 게시물에서는 Windows OS의 현재 활성 프로세스 목록을 가져오는 몇 가지 대체 Python 방법을 살펴보겠습니다.

원하는 결과를 얻으려면 먼저 Python 메서드를 설명하겠습니다. 그런 다음 동일한 작업을 수행하기 위해 Windows 명령 프로세서의 명령을 검토하겠습니다.

핍 설치 wmi

위의 코드를 터미널에 복사하세요.

 #import wmi module import wmi # Initializise the wmi constructor f = wmi.WMI() # Print the header print(&apos;Printing the pid Process name&apos;) # all the running processes for process in f.Win32_Process(): print(f&apos;{process.ProcessId:<5} {process.name}') < pre> <p> <strong>Output:</strong> </p> <img src="//techcodeview.com/img/python-tutorial/88/python-win32-process.webp" alt="Python Win32 Process"> <br> <img src="//techcodeview.com/img/python-tutorial/88/python-win32-process-2.webp" alt="Python Win32 Process"> <p>The WMI() function of the wmi library is first initialized. This enables us to access its internal functions, such as WMI.Win32_Service, WMI.Win32_Process, and WMI.Win32_Printjob, each of which is intended to carry out a certain duty. To obtain a list of the system&apos;s active processes, we would use the WMI.Win32_Process function. After that, we iterated through all the running processes and placed them in the variable process by calling the function WMI.Win32_Process(). The corresponding attributes were then used to derive the process&apos;s ProcessID (pid) and ProcessName (name). To add padding to the output and properly align it, we used F-strings for the output.</p> <p>Now let&apos;s go through different methods of module Win32process.</p> <h3>1. STARTUPINFO</h3> <p>In this method, we create a new STARTUPINFO object.</p> <p>Let&apos;s understand how to create this, which is given below:</p> <p>win32process.STARTUPINFO</p> <p>PySTARTUPINFO = STARTUPINFO()</p> <h3>2. beginthreadex</h3> <p>In this method, we create a new thread.</p> <p>Let&apos;s understand how to create this, which is given below:</p> <p>win32process.beginthreadex</p> <p>PyHANDLE, int = beginthreadex(sa, stackSize , entryPoint , args , flags )</p> <p>Let&apos;s understand its parameters is given below</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>sa:</td> PySECURITY_ATTRIBUTES(The security attributes, or None) </tr><tr><td>stackSize :</td> int (The new thread&apos;s stack size, or 0 for the default size.) </tr><tr><td>entryPoint :</td> function (It is a thread function) </tr><tr><td>args :</td> tuple </tr><tr><td>flags :</td> int </tr></ul> <p>CREATE_SUSPENDED is an option for delaying the start of a thread.</p> <p> <strong>The thread handle and thread ID are returned as a tuple as the outcome.</strong> </p> <h3>3. CreateProcess</h3> <p>win32process.CreateProcess PyHANDLE, PyHANDLE, int, int = CreateProcess(appName, commandLine , processAttributes , threadAttributes , bInheritHandles , dwCreationFlags , newEnvironment , currentDirectory , startupinfo ) establishes a new process and the main thread for it. The newly created process runs the designated executable file.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>appName:</td> string (executable module&apos;s name, or None) </tr><tr><td>Commandline:</td> string (command-line argument, or Nothing) </tr><tr><td>processAttributes:</td> PySECURITY_ATTRIBUTES (attributes of process security, or None) </tr><tr><td>threadAttributes:</td> PySECURITY_ATTRIBUTES (aspects of thread security, or None) </tr><tr><td>bInheritHandles:</td> int </tr><tr><td>dwCreationFlags:</td> int </tr></ul> <h3>4. CreateRemoteThread</h3> <p>win32process.CreateRemoteThread PyHANDLE, int = CreateRemoteThread(hprocess, sa , stackSize , entryPoint , Parameter , flags ) establishes a thread that executes in another process&apos;s virtual address space.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hprocess :</td> PyHANDLE (the remote process&apos;s handle) </tr><tr><td>sa :</td> PySECURITY_ATTRIBUTES (Security characteristics, or None) </tr><tr><td>stackSize :</td> int (The new thread&apos;s stack size, or 0 for the default size.) </tr><tr><td>entryPoint :</td> function (The address of the thread function.) </tr><tr><td>Parameter :</td> int (a void pointer that served as the argument given to the function) </tr><tr><td>flags :</td> int </tr></ul> <p>The thread handle and thread ID are returned as a tuple as the outcome.</p> <h3>5. CreateProcessAsUser</h3> <p>win32process.CreateProcessAsUser creates a new process with the provided user as its context.</p> <p>PyHANDLE, PyHANDLE, int, int = CreateProcessAsUser(hToken, appName , commandLine , processAttributes , threadAttributes , bInheritHandles , dwCreationFlags , newEnvironment , currentDirectory , startupinfo )</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hToken:</td> PyHANDLE (Handle to a token that indicates a user who is currently logged in) </tr><tr><td>appName:</td> string (executable module&apos;s name, or None) </tr><tr><td>commandLine:</td> string (command-line argument, or Nothing) </tr><tr><td>processAttributes:</td> PySECURITY_ATTRIBUTES (attributes of process security, or None) </tr><tr><td>threadAttributes:</td> PySECURITY_ATTRIBUTES (aspects of thread security, or None) </tr><tr><td>bInheritHandles:</td> int (the inheritance flag handle) </tr><tr><td>dwCreationFlags:</td> int (creating of flags) </tr><tr><td>newEnvironment:</td> None (A dictionary of stringor Unicode pair definitions to specify the process environment, or None to use the default environment.) </tr><tr><td>currentDirectory:</td> string (name of the current directory, or None) </tr><tr><td>startupinfo:</td> PySTARTUPINFO (a STARTUPINFO object that describes the appearance of the new process&apos;s main window.) </tr></ul> <p> <strong>Consequently, a tuple of (hProcess, hThread, dwProcessId, dwThreadId)</strong> </p> <h3>6. GetCurrentProcess</h3> <p>win32process.GetCurrentProcess obtains a fictitious handle for the active process.</p> <p>int = GetCurrentProcess()</p> <h3>7. GetCurrentProcessId</h3> <p>win32process.GetCurrentProcessId reveals the caller process&apos;s unique process identification.</p> <p>int = GetCurrentProcessId()</p> <h3>8. GetProcessVersion</h3> <p>win32process.GetProcessVersion reveals the system&apos;s main and minor version numbers, which are needed to conduct a specific process.</p> <p>int = GetProcessVersion(processId)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>processId:</td> int (a designation for the desired process.) </tr></ul> <h3>9. GetCurrentProcessId</h3> <p>win32process.GetCurrentProcessId reveals the caller process&apos;s unique process identification.</p> <p>int = GetCurrentProcessId()</p> <h3>10. GetStartupInfo</h3> <p>win32process.GetStartupInfo reveals the STARTUPINFO structure&apos;s contents, which were supplied when the caller process was established.</p> <p>PySTARTUPINFO = GetStartupInfo()</p> <h3>11. GetPriorityClass</h3> <p>win32process.GetPriorityClass</p> <p>int = GetPriorityClass(handle)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE (to the thread&apos;s handle) </tr></ul> <h3>12. GetExitCodeThread</h3> <p>win32process.GetExitCodeThread</p> <p>int = GetExitCodeThread(handle)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE (to the thread&apos;s handle) </tr></ul> <h3>13. GetExitCodeProcess</h3> <p>win32process.GetExitCodeProcess</p> <p>int = GetExitCodeProcess(handle)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE (to the thread&apos;s handle) </tr></ul> <h3>14. GetWindowThreadProcessId</h3> <p>win32process.GetWindowThreadProcessId returns the thread and process IDs that were responsible for the provided window&apos;s creation.</p> <p>int, int = GetWindowThreadProcessId(hwnd)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hwnd:</td> int (this parameter handles the window) </tr></ul> <p> <strong>Consequently, a tuple of (threadId, processId)</strong> </p> <h3>15. SetThreadPriority</h3> <p>win32process.SetThreadPriority</p> <p>SetThreadPriority(handle, nPriority)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE (This parameter handles the thread) </tr><tr><td>nPriority:</td> int (This parameter thread the priority level) </tr></ul> <h3>16. GetThreadPriority</h3> <p>win32process.GetThreadPriority</p> <p>int = GetThreadPriority(handle)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE (this parameter handles the threads) </tr></ul> <h3>17. GetProcessPriorityBoost</h3> <p>win32process.GetProcessPriorityBoost determines whether a process&apos;s dynamic priority adjustment is enabled.</p> <p>bool = GetProcessPriorityBoost(Process)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Process:</td> PyHANDLE (This parameter handles to a process) </tr></ul> <h3>18. SetProcessPriorityBoost</h3> <p>win32process.SetProcessPriorityBoost enables or disables a process&apos;s dynamic priority adjustment.</p> <p>SetProcessPriorityBoost(Process, DisablePriorityBoost)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Process:</td> PyHANDLE (This parameter handles a process) </tr><tr><td>DisablePriorityBoost:</td> boolean (This parameter indicates True to disable and False to enable) </tr></ul> <h3>19. GetThreadPriorityBoost</h3> <p>win32process.GetThreadPriorityBoost</p> <p>determines whether a thread&apos;s dynamic priority adjustment is enabled.</p> <p>bool = GetThreadPriorityBoost(Thread)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Thread:</td> PyHANDLE (This parameter handles to a thread) </tr></ul> <h3>20. SetThreadPriorityBoost</h3> <p>win32process.SetThreadPriorityBoost enables or disables a thread&apos;s dynamic priority adjustment.</p> <p>SetThreadPriorityBoost(Thread, DisablePriorityBoost)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Thread:</td> PyHANDLE (This parameter handles to a thread) </tr><tr><td>DisablePriorityBoost:</td> boolean ((This parameter indicates True to disable and False to enable) </tr></ul> <h3>21. GetThreadIOPendingFlag</h3> <p>win32process.GetThreadIOPendingFlag determines whether a thread has any open IO requests.</p> <p>bool = GetThreadIOPendingFlag(Thread)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Thread:</td> PyHANDLE (This parameter handles to a thread) </tr></ul> <h3>22. GetThreadTimes</h3> <p>win32process.GetThreadTimes</p> <p>It returns the time statistics for a thread.</p> <p>dict = GetThreadTimes(Thread)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Thread:</td> PyHANDLE (This parameter handles to a thread) </tr></ul> <h3>23. GetProcessId</h3> <p>int = GetProcessId(Process)</p> <p>It returns the Pid for a process handle.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Process:</td> PyHANDLE (This parameter handles to a thread) </tr></ul> <h3>24. SetPriorityClass</h3> <p>win32process.SetPriorityClass</p> <p>SetPriorityClass(handle, dwPriorityClass)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE (This parameter handles to the process) </tr><tr><td>dwPriorityClass:</td> int (This parameter gives priority class value) </tr></ul> <h3>25. AttachThreadInput</h3> <p>win32process.AttachThreadInput connects and disconnects the input of two threads.</p> <p>AttachThreadInput(idAttach, idAttachTo, Attach)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>idAttach:</td> int (This parameter shows id of a thread) </tr><tr><td>idAttachTo:</td> int (This parameter shows the id of the thread) </tr><tr><td>Attach:</td> bool (determines whether a thread should be joined or disconnected.) </tr></ul> <h3>26. SetThreadIdealProcessor</h3> <p>win32process.SetThreadIdealProcessor</p> <p> <strong>Syntax</strong> </p> <pre>win32process.SetThreadIdealProcessor( handle, dwIdealProcessor )</pre> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE ( handle to the thread of interest ) </tr><tr><td>dwIdealProcessor:</td> int ( ideal processor number ) </tr></ul> <p> <strong>Return type</strong> </p> <p>This method return the int value</p> <h3>27. GetProcessAffinityMask</h3> <p>win32process.GetProcessAffinityMask</p> <p> <strong>Syntax</strong> </p> <pre>win32process.GetProcessAffinityMask( hProcess )</pre> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( handle to the process of interest ) </tr></ul> <p> <strong>Return type</strong> </p> <p>This method returns a tuple of ( process affinity mask, system affinity mask ).</p> <h3>28. SetProcessAffinityMask</h3> <p>win32process.SetProcessAffinityMask</p> <p> <strong>Syntax</strong> </p> <pre>win32process.SetProcessAffinityMask( hProcess, mask )</pre> <p>Sets a processor affinity mask for a specified process.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( handle to the process of interest ) </tr><tr><td>mask:</td> int ( a processor affinity mask ) </tr></ul> <h4>Note: Some platforms do not have this feature.</h4> <h3>29. SetThreadAffinityMask</h3> <p>win32process.SetThreadAffinityMask</p> <p> <strong>Syntax</strong> </p> <pre>win32process.SetThreadAffinityMask( hThread, ThreadAffinityMask )</pre> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hThread:</td> PyHANDLE ( handle to the thread of interest ) </tr><tr><td>ThreadAffinityMask:</td> int ( a processor affinity mask ) </tr></ul> <p> <strong>Return type</strong> </p> <p>This method returns an int value.</p> <h3>30. SuspendThread</h3> <p>win32process.SuspendThread</p> <p> <strong>Syntax</strong> </p> <pre>int = SuspendThread( handle )</pre> <p>Suspends the specified thread.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE ( handle to the thread ) </tr></ul> <p> <strong>Return value</strong> </p> <p>The return value is the thread&apos;s previous suspend count</p> <h3>31. ResumeThread</h3> <p>win32process.ResumeThread</p> <p> <strong>Syntax</strong> </p> <pre>int = ResumeThread( handle )</pre> <p>Resumes the specified thread. When the suspend count is decremented to zero, the execution of the thread is resumed.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE ( handle to the thread ) </tr></ul> <p> <strong>Return value</strong> </p> <p>The return value is the thread&apos;s previous suspend count</p> <h3>32. TerminateProcess</h3> <p>win32process.TerminateProcess</p> <p> <strong>Syntax</strong> </p> <pre>TerminateProcess( handle, exitCode )</pre> <p> <strong>Parameters</strong> </p> <ul> <tr><td>handle:</td> PyHANDLE ( handle to the process ) </tr><tr><td>exitCode:</td> int ( The exit code for the process ) </tr></ul> <h3>33. xitProcess</h3> <p>win32process.ExitProcess</p> <ul> <tr><td>ExitProcess:</td> The process&apos;s end and all of its threads </tr></ul> <p> <strong>Parameters</strong> </p> <ul> <tr><td>exitCode:</td> int (Exit code information is provided for the process, and all threads that are terminated as a result of this call.) </tr></ul> <p>The best way to stop a process is with ExitProcess. A clean process shutdown is provided by this function. This includes contacting each associated dynamic-link library&apos;s (DLL) entry-point function with a value indicating that the process is separating from the DLL. The DLLs associated with the process are not informed of the process termination if a process terminates by invoking win32process::TerminateProcess.</p> <h3>34. EnumProcesses</h3> <p>win32process.EnumProcesses</p> <p> <strong>Syntax</strong> </p> <pre>( long,.... ) = EnumProcesses()</pre> <p>Provides Pids for activities that are actually running.</p> <h3>35. EnumProcessModules</h3> <p>win32process.EnumProcessModules</p> <p> <strong>Syntax</strong> </p> <pre>( long,.... ) = EnumProcessModules( hProcess )</pre> <p>Lists loaded modules for a process handle</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( Process handle as returned by OpenProcess ) </tr></ul> <h3>36. EnumProcessModulesEx</h3> <p>win32process.EnumProcessModulesEx</p> <p> <strong>Syntax</strong> </p> <pre>( long,.... ) = EnumProcessModulesEx( hProcess, FilterFlag )</pre> <p>lists the 32- or 64-bit modules that a process has loaded.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess :</td> PyHANDLE ( The process handle that OpenProcess returned ) FilterFlag=LIST_MODULES_DEFAULT : int ( choose whether to return 32-bit or 64-bit modules. ) needs Windows Vista or later. </tr></ul> <h3>37. GetModuleFileNameEx</h3> <p>win32process.GetModuleFileNameEx</p> <p> <strong>Syntax</strong> </p> <pre>PyUNICODE = GetModuleFileNameEx( hProcess, hModule )</pre> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( The process handle that OpenProcess returned ) </tr><tr><td>hModule:</td> PyHANDLE ( This parameter handles the modules ) </tr></ul> <h3>38. GetProcessMemoryInfo</h3> <p>win32process.GetProcessMemoryInfo</p> <p> <strong>Syntax</strong> </p> <pre>dict = GetProcessMemoryInfo( hProcess )</pre> <p>A dict representing a PROCESS_MEMORY_COUNTERS struct is returned as the process memory statistics.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( Process handle as returned by OpenProcess ) </tr></ul> <h3>39. GetProcessTimes</h3> <p>win32process.GetProcessTimes</p> <p> <strong>Syntax</strong> </p> <pre>dict = GetProcessTimes( hProcess )</pre> <p>Obtain time statistics for a process using its handle. (In 100 nanosecond units for UserTime and KernelTime)</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( Process handle as returned by OpenProcess ) </tr></ul> <h3>40. GetProcessIoCounters</h3> <p>win32process.GetProcessIoCounters</p> <p> <strong>Syntax</strong> </p> <pre>dict = GetProcessIoCounters( hProcess )</pre> <p>I/O statistics for a process are returned as a dictionary corresponding to an IO_COUNTERS struct.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( Process handle as returned by OpenProcess ) </tr></ul> <h3>41. GetProcessWindowStation</h3> <p>win32process.GetProcessWindowStation</p> <p> <strong>Syntax</strong> </p> <pre>GetProcessWindowStation()</pre> <p>Returns a handle to the window station for the calling process.</p> <h3>42. GetProcessWorkingSetSize</h3> <p>win32process.GetProcessWorkingSetSize</p> <p> <strong>Syntax</strong> </p> <pre>int,int = GetProcessWorkingSetSize( hProcess )</pre> <p>A process&apos;s minimum and maximum working set sizes are returned.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess:</td> PyHANDLE ( Process handle as returned by win32api::OpenProcess ) </tr></ul> <h3>43. SetProcessWorkingSetSize</h3> <p>win32process.SetProcessWorkingSetSize</p> <p> <strong>Syntax</strong> </p> <pre>SetProcessWorkingSetSize( hProcess, MinimumWorkingSetSize, MaximumWorkingSetSize )</pre> <p>Sets minimum and maximum working set sizes for a process.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>hProcess :</td> PyHANDLE ( Process handle as returned by OpenProcess ) </tr><tr><td>MinimumWorkingSetSize :</td> int ( Minimum number of bytes to keep in physical memory ) </tr><tr><td>MaximumWorkingSetSize :</td> int ( Maximum number of bytes to keep in physical memory ) </tr></ul> <h4>NOTE: To entirely swap out the procedure, set both min and max to -1.</h4> <h3>44. GetProcessShutdownParameters</h3> <p>win32process.GetProcessShutdownParameters</p> <p> <strong>Syntax</strong> </p> <pre>int,int = GetProcessShutdownParameters()</pre> <p>Reveals the process&apos;s current termination level and triggers.</p> <p>The range is 000-0FF. windows reserved, Last, 200-2FF Middle, First, 300-3FF, and Fourth, 400-4FF Windows reserves.</p> <h3>45. SetProcessShutdownParameters</h3> <p>win32process.SetProcessShutdownParameters</p> <p> <strong>Syntax</strong> </p> <pre>SetProcessShutdownParameters(Level, Flags)</pre> <p>Sets the process&apos;s flags and termination priority.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Level:</td> int (This parameter shows higher priority equals earlier) </tr><tr><td>Flags:</td> int (This parameter shows only SHUTDOWN NORETRY is valid at the moment). </tr></ul> <p>The range is 000-0FF. 100-1FF Last, 200-2FF Middle, 300-3FF First, 400-4FF, and reserved by windows window reserved.</p> <h3>46. GetGuiResources</h3> <p>win32process.GetGuiResources</p> <p> <strong>Syntax</strong> </p> <pre>int = GetGuiResources(Process, Flags )</pre> <p>Gives the amount of GDI or user object handles that a process is holding.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Process:</td> PyHANDLE (This parameter Win32api::OpenProcess&apos;s returned handle to a process) </tr><tr><td>Flags:</td> int (This parameter shows either GR USEROBJECTS or GR GDIOBJECTS (from win32con)) </tr></ul> <h3>47. IsWow64Process</h3> <p>win32process.IsWow64Process</p> <p> <strong>Syntax</strong> </p> <pre>bool = IsWow64Process(Process)</pre> <p>Identifies whether WOW64 is currently running the specified process.</p> <p> <strong>Parameters</strong> </p> <ul> <tr><td>Process=None:</td> PyHANDLE (Process handle returned by win32api::OpenProcess, win32api::GetCurrentProcess, etc.; if None (the default) is given, the current process handle will be used.) </tr></ul> <p>Let&apos;s see its Return Value.</p> <p>The return value is False if the operating system does not provide this function (ie,</p> <p>a NotImplemented exception will never be thrown). However, a</p> <p>win32process.error exception to this is normally thrown if the function is available</p> <p>but ineffective.</p> <h2>Conclusion</h2> <p>In this article, we have discussed Python win32 process. And also, we have discussed the different types of methods and their parameters and return values one by one.</p> <hr></5}>

매개변수

    핸들:PyHANDLE(관심 있는 스레드에 대한 핸들)dwIdealProcessor:int (이상적인 프로세서 번호)

반환 유형

이 메소드는 int 값을 반환합니다.

타이프스크립트 foreach 루프

27. GetProcessAffinityMask

win32process.GetProcessAffinityMask

통사론

win32process.GetProcessAffinityMask( hProcess )

매개변수

    h프로세스:PyHANDLE(관심 있는 프로세스에 대한 핸들)

반환 유형

이 메서드는 (프로세스 선호도 마스크, 시스템 선호도 마스크)의 튜플을 반환합니다.

28. SetProcessAffinityMask

win32process.SetProcessAffinityMask

통사론

win32process.SetProcessAffinityMask( hProcess, mask )

지정된 프로세스에 대한 프로세서 선호도 마스크를 설정합니다.

매개변수

    h프로세스:PyHANDLE(관심 있는 프로세스에 대한 핸들)마스크:int(프로세서 선호도 마스크)

참고: 일부 플랫폼에는 이 기능이 없습니다.

29. SetThreadAffinityMask

win32process.SetThreadAffinityMask

통사론

win32process.SetThreadAffinityMask( hThread, ThreadAffinityMask )

매개변수

    h스레드:PyHANDLE(관심 있는 스레드에 대한 핸들)스레드어피니티마스크:int(프로세서 선호도 마스크)

반환 유형

이 메서드는 int 값을 반환합니다.

30. 일시 중단 스레드

win32process.SuspendThread

통사론

int = SuspendThread( handle )

지정된 스레드를 일시 중단합니다.

매개변수

    핸들:PyHANDLE(스레드 핸들)

반환 값

반환 값은 스레드의 이전 일시 중단 횟수입니다.

31. 이력서 스레드

win32process.ResumeThread

통사론

int = ResumeThread( handle )

지정된 스레드를 재개합니다. 일시중단 횟수가 0으로 감소하면 스레드 실행이 재개됩니다.

매개변수

    핸들:PyHANDLE(스레드 핸들)

반환 값

반환 값은 스레드의 이전 일시 중단 횟수입니다.

32. 종료프로세스

win32process.TerminateProcess

통사론

TerminateProcess( handle, exitCode )

매개변수

    핸들:PyHANDLE(프로세스 핸들)종료 코드:int (프로세스의 종료 코드)

33. xit프로세스

win32process.ExitProcess

    종료프로세스:프로세스의 끝과 모든 스레드

매개변수

    종료 코드:int(프로세스 및 이 호출의 결과로 종료되는 모든 스레드에 대한 종료 코드 정보가 제공됩니다.)

프로세스를 중지하는 가장 좋은 방법은 ExitProcess를 사용하는 것입니다. 이 기능을 통해 완전한 프로세스 종료가 제공됩니다. 여기에는 프로세스가 DLL에서 분리되고 있음을 나타내는 값을 사용하여 연관된 각 DLL(동적 연결 라이브러리)의 진입점 함수에 연결하는 것이 포함됩니다. 프로세스가 win32process::TerminateProcess를 호출하여 종료되는 경우 프로세스와 연결된 DLL에는 프로세스 종료에 대한 알림이 전달되지 않습니다.

34. 열거형 프로세스

win32process.EnumProcesses

통사론

( long,.... ) = EnumProcesses()

실제로 실행 중인 활동에 대한 Pid를 제공합니다.

35. EnumProcessModule

win32process.EnumProcessModules

통사론

( long,.... ) = EnumProcessModules( hProcess )

프로세스 핸들에 대해 로드된 모듈을 나열합니다.

매개변수

    h프로세스:PyHANDLE(OpenProcess가 반환한 프로세스 핸들)

36. EnumProcessModulesEx

win32process.EnumProcessModulesEx

통사론

( long,.... ) = EnumProcessModulesEx( hProcess, FilterFlag )

프로세스가 로드한 32비트 또는 64비트 모듈을 나열합니다.

매개변수

    h프로세스:PyHANDLE ( OpenProcess가 반환한 프로세스 핸들 ) FilterFlag=LIST_MODULES_DEFAULT : int ( 32비트 또는 64비트 모듈을 반환할지 선택합니다. )에는 Windows Vista 이상이 필요합니다.

37. GetModuleFileNameEx 가져오기

win32process.GetModuleFileNameEx

통사론

PyUNICODE = GetModuleFileNameEx( hProcess, hModule )

매개변수

    h프로세스:PyHANDLE(OpenProcess가 반환한 프로세스 핸들)h모듈:PyHANDLE(이 매개변수는 모듈을 처리합니다)

38. GetProcessMemoryInfo

win32process.GetProcessMemoryInfo

통사론

dict = GetProcessMemoryInfo( hProcess )

PROCESS_MEMORY_COUNTERS 구조체를 나타내는 딕셔너리가 프로세스 메모리 통계로 반환됩니다.

매개변수

    h프로세스:PyHANDLE(OpenProcess가 반환한 프로세스 핸들)

39. GetProcessTimes

win32process.GetProcessTimes

통사론

dict = GetProcessTimes( hProcess )

핸들을 사용하여 프로세스에 대한 시간 통계를 얻습니다. (UserTime 및 KernelTime의 경우 100나노초 단위)

자바 익명 함수

매개변수

    h프로세스:PyHANDLE(OpenProcess가 반환한 프로세스 핸들)

40. GetProcessIoCounters

win32process.GetProcessIoCounters

통사론

dict = GetProcessIoCounters( hProcess )

프로세스에 대한 I/O 통계는 IO_COUNTERS 구조체에 해당하는 사전으로 반환됩니다.

매개변수

    h프로세스:PyHANDLE(OpenProcess가 반환한 프로세스 핸들)

41. GetProcessWindowStation

win32process.GetProcessWindowStation

통사론

GetProcessWindowStation()

호출 프로세스에 대한 윈도우 스테이션에 대한 핸들을 반환합니다.

42. GetProcessWorkingSetSize

win32process.GetProcessWorkingSetSize

통사론

int,int = GetProcessWorkingSetSize( hProcess )

프로세스의 최소 및 최대 작업 세트 크기가 반환됩니다.

매개변수

    h프로세스:PyHANDLE( win32api::OpenProcess 에서 반환된 프로세스 핸들)

43. SetProcessWorkingSetSize

win32process.SetProcessWorkingSetSize

통사론

SetProcessWorkingSetSize( hProcess, MinimumWorkingSetSize, MaximumWorkingSetSize )

프로세스의 최소 및 최대 작업 세트 크기를 설정합니다.

매개변수

    h프로세스:PyHANDLE(OpenProcess가 반환한 프로세스 핸들)최소WorkingSetSize:int (물리적 메모리에 보관할 최소 바이트 수)최대작업설정크기:int (물리적 메모리에 보관할 최대 바이트 수)

참고: 프로시저를 완전히 바꾸려면 최소 및 최대를 모두 -1로 설정하십시오.

44. GetProcessShutdownParameters

win32process.GetProcessShutdownParameters

통사론

int,int = GetProcessShutdownParameters()

프로세스의 현재 종료 수준과 트리거를 표시합니다.

범위는 000-0FF입니다. windows Reserved, Last, 200-2FF Middle, First, 300-3FF 및 Fourth, 400-4FF Windows Reserve.

45. SetProcessShutdownParameters

win32process.SetProcessShutdownParameters

통사론

SetProcessShutdownParameters(Level, Flags)

프로세스의 플래그와 종료 우선순위를 설정합니다.

매개변수

    수준:int(이 매개변수는 더 높은 우선순위가 이전과 같음을 나타냄)플래그:int(이 매개변수는 현재 SHUTDOWN NORETRY만 유효함을 나타냅니다.)

범위는 000-0FF입니다. 100-1FF 마지막, 200-2FF 중간, 300-3FF 처음, 400-4FF 및 Windows 창 예약에 의해 예약됨.

46. ​​GetGui리소스

win32process.GetGuiResources

통사론

int = GetGuiResources(Process, Flags )

프로세스가 보유하고 있는 GDI 또는 사용자 개체 핸들의 양을 제공합니다.

매개변수

    프로세스:PyHANDLE(이 매개변수는 Win32api::OpenProcess가 프로세스에 반환한 핸들)플래그:int(이 매개변수는 GR USEROBJECTS 또는 GR GDIOBJECTS(win32con에서)를 표시합니다.)

47. IsWow64프로세스

win32process.IsWow64Process

통사론

bool = IsWow64Process(Process)

WOW64가 현재 지정된 프로세스를 실행 중인지 식별합니다.

매개변수

    프로세스=없음:PyHANDLE(win32api::OpenProcess, win32api::GetCurrentProcess 등에서 반환된 프로세스 핸들. None(기본값)이 지정되면 현재 프로세스 핸들이 사용됩니다.)

반환 값을 살펴보겠습니다.

운영 체제가 이 기능을 제공하지 않는 경우 반환 값은 False입니다(예:

NotImplemented 예외는 발생하지 않습니다.) 그러나

함수를 사용할 수 있는 경우 win32process.error 예외가 일반적으로 발생합니다.

하지만 효과가 없습니다.

결론

이 기사에서는 Python win32 프로세스에 대해 논의했습니다. 그리고 다양한 메소드의 종류와 매개변수, 반환값에 대해 하나씩 살펴보았습니다.