當前位置: 首頁>>代碼示例>>Python>>正文


Python win32con.PROCESS_QUERY_INFORMATION屬性代碼示例

本文整理匯總了Python中win32con.PROCESS_QUERY_INFORMATION屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32con.PROCESS_QUERY_INFORMATION屬性的具體用法?Python win32con.PROCESS_QUERY_INFORMATION怎麽用?Python win32con.PROCESS_QUERY_INFORMATION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在win32con的用法示例。


在下文中一共展示了win32con.PROCESS_QUERY_INFORMATION屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cmdline

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_cmdline(self):
        sys_value = re.sub(' +', ' ', win32api.GetCommandLine()).strip()
        psutil_value = ' '.join(psutil.Process().cmdline())
        self.assertEqual(sys_value, psutil_value)

    # XXX - occasional failures

    # def test_cpu_times(self):
    #     handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
    #                                   win32con.FALSE, os.getpid())
    #     self.addCleanup(win32api.CloseHandle, handle)
    #     sys_value = win32process.GetProcessTimes(handle)
    #     psutil_value = psutil.Process().cpu_times()
    #     self.assertAlmostEqual(
    #         psutil_value.user, sys_value['UserTime'] / 10000000.0,
    #         delta=0.2)
    #     self.assertAlmostEqual(
    #         psutil_value.user, sys_value['KernelTime'] / 10000000.0,
    #         delta=0.2) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:21,代碼來源:test_windows.py

示例2: test_io_counters

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_io_counters(self):
        handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                      win32con.FALSE, os.getpid())
        self.addCleanup(win32api.CloseHandle, handle)
        sys_value = win32process.GetProcessIoCounters(handle)
        psutil_value = psutil.Process().io_counters()
        self.assertEqual(
            psutil_value.read_count, sys_value['ReadOperationCount'])
        self.assertEqual(
            psutil_value.write_count, sys_value['WriteOperationCount'])
        self.assertEqual(
            psutil_value.read_bytes, sys_value['ReadTransferCount'])
        self.assertEqual(
            psutil_value.write_bytes, sys_value['WriteTransferCount'])
        self.assertEqual(
            psutil_value.other_count, sys_value['OtherOperationCount'])
        self.assertEqual(
            psutil_value.other_bytes, sys_value['OtherTransferCount']) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:20,代碼來源:test_windows.py

示例3: _scan_for_self

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def _scan_for_self(self):
        win32api.Sleep(2000) # sleep to give time for process to be seen in system table.
        basename = self.cmdline.split()[0]
        pids = win32process.EnumProcesses()
        if not pids:
            UserLog.warn("WindowsProcess", "no pids", pids)
        for pid in pids:
            try:
                handle = win32api.OpenProcess(
                    win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ,
                        pywintypes.FALSE, pid)
            except pywintypes.error, err:
                UserLog.warn("WindowsProcess", str(err))
                continue
            try:
                modlist = win32process.EnumProcessModules(handle)
            except pywintypes.error,err:
                UserLog.warn("WindowsProcess",str(err))
                continue 
開發者ID:kdart,項目名稱:pycopia,代碼行數:21,代碼來源:WindowsServer.py

示例4: get_pid_owner

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def get_pid_owner(self, fd, pid):
        try:
            proc = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, False, pid)
            token = win32security.OpenProcessToken(proc, win32con.TOKEN_QUERY)
            user_sid, user_attr = win32security.GetTokenInformation(token,
                        win32security.TokenUser)
            user = win32security.LookupAccountSid(None, user_sid)
            return user_sid, user[0], user[1]
        except win32api.error as e:
            self.logEx("error",
                "%s failed" % funcname,
                ("exception",   e),
                ("function",    e.funcname),
                ("error",       "[%(winerror)d] %(strerror)s" % e),
                None,
                ("process",     pid),)
            raise 
開發者ID:grawity,項目名稱:code,代碼行數:19,代碼來源:win32-identd.py

示例5: test_num_handles_increment

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_num_handles_increment(self):
        p = psutil.Process(os.getpid())
        before = p.num_handles()
        handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                      win32con.FALSE, os.getpid())
        after = p.num_handles()
        self.assertEqual(after, before + 1)
        win32api.CloseHandle(handle)
        self.assertEqual(p.num_handles(), before) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:11,代碼來源:test_windows.py

示例6: test_nice

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_nice(self):
        handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                      win32con.FALSE, os.getpid())
        self.addCleanup(win32api.CloseHandle, handle)
        sys_value = win32process.GetPriorityClass(handle)
        psutil_value = psutil.Process().nice()
        self.assertEqual(psutil_value, sys_value) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:9,代碼來源:test_windows.py

示例7: test_memory_info

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_memory_info(self):
        handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                      win32con.FALSE, self.pid)
        self.addCleanup(win32api.CloseHandle, handle)
        sys_value = win32process.GetProcessMemoryInfo(handle)
        psutil_value = psutil.Process(self.pid).memory_info()
        self.assertEqual(
            sys_value['PeakWorkingSetSize'], psutil_value.peak_wset)
        self.assertEqual(
            sys_value['WorkingSetSize'], psutil_value.wset)
        self.assertEqual(
            sys_value['QuotaPeakPagedPoolUsage'], psutil_value.peak_paged_pool)
        self.assertEqual(
            sys_value['QuotaPagedPoolUsage'], psutil_value.paged_pool)
        self.assertEqual(
            sys_value['QuotaPeakNonPagedPoolUsage'],
            psutil_value.peak_nonpaged_pool)
        self.assertEqual(
            sys_value['QuotaNonPagedPoolUsage'], psutil_value.nonpaged_pool)
        self.assertEqual(
            sys_value['PagefileUsage'], psutil_value.pagefile)
        self.assertEqual(
            sys_value['PeakPagefileUsage'], psutil_value.peak_pagefile)

        self.assertEqual(psutil_value.rss, psutil_value.wset)
        self.assertEqual(psutil_value.vms, psutil_value.pagefile) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:28,代碼來源:test_windows.py

示例8: test_wait

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_wait(self):
        handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION,
                                      win32con.FALSE, self.pid)
        self.addCleanup(win32api.CloseHandle, handle)
        p = psutil.Process(self.pid)
        p.terminate()
        psutil_value = p.wait()
        sys_value = win32process.GetExitCodeProcess(handle)
        self.assertEqual(psutil_value, sys_value) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:11,代碼來源:test_windows.py

示例9: test_num_handles

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_num_handles(self):
        import ctypes
        import ctypes.wintypes
        PROCESS_QUERY_INFORMATION = 0x400
        handle = ctypes.windll.kernel32.OpenProcess(
            PROCESS_QUERY_INFORMATION, 0, os.getpid())
        self.addCleanup(ctypes.windll.kernel32.CloseHandle, handle)
        hndcnt = ctypes.wintypes.DWORD()
        ctypes.windll.kernel32.GetProcessHandleCount(
            handle, ctypes.byref(hndcnt))
        sys_value = hndcnt.value
        psutil_value = psutil.Process().num_handles()
        ctypes.windll.kernel32.CloseHandle(handle)
        self.assertEqual(psutil_value, sys_value + 1) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:16,代碼來源:test_windows.py

示例10: vmmap

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def vmmap(pid, is_64=True):
    base = 0
    if is_64:
        mbi = MEMORY_BASIC_INFORMATION_64()
        addr_type = wintypes.LARGE_INTEGER
    else:
        mbi = MEMORY_BASIC_INFORMATION_32()
        addr_type = wintypes.DWORD
    proc = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, 0, pid)
    
    maps = []
    while windll.kernel32.VirtualQueryEx(proc.handle, addr_type(base), ctypes.byref(mbi), ctypes.sizeof(mbi)) > 0:
        mapperm = 0
        if mbi.Protect & win32con.PAGE_EXECUTE:
            mapperm = SEG_PROT_X
        elif mbi.Protect & win32con.PAGE_EXECUTE_READ:
            mapperm = SEG_PROT_X | SEG_PROT_R
        elif mbi.Protect & win32con.PAGE_EXECUTE_READWRITE:
            mapperm = SEG_PROT_X | SEG_PROT_R | SEG_PROT_W
        elif mbi.Protect & win32con.PAGE_EXECUTE_WRITECOPY:
            mapperm = SEG_PROT_X | SEG_PROT_R
        elif mbi.Protect & win32con.PAGE_NOACCESS:
            mapperm = 0
        elif mbi.Protect & win32con.PAGE_READONLY:
            mapperm = SEG_PROT_R
        elif mbi.Protect & win32con.PAGE_READWRITE:
            mapperm = SEG_PROT_R | SEG_PROT_W
        elif mbi.Protect & win32con.PAGE_WRITECOPY:
            mapperm = SEG_PROT_R
        #print hex(mbi.BaseAddress) +"\t"+ hex(mbi.BaseAddress + mbi.RegionSize) +"\t"+ hex(mapperm)
        maps.append((mbi.BaseAddress, mbi.BaseAddress + mbi.RegionSize, mapperm, ""))
        base += mbi.RegionSize
    
    win32api.CloseHandle(proc)
    return maps 
開發者ID:andreafioraldi,項目名稱:IDAngr,代碼行數:37,代碼來源:win_vmmap.py

示例11: test_num_handles

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def test_num_handles(self):
        import ctypes
        import ctypes.wintypes
        PROCESS_QUERY_INFORMATION = 0x400
        handle = ctypes.windll.kernel32.OpenProcess(
            PROCESS_QUERY_INFORMATION, 0, self.pid)
        self.addCleanup(ctypes.windll.kernel32.CloseHandle, handle)

        hndcnt = ctypes.wintypes.DWORD()
        ctypes.windll.kernel32.GetProcessHandleCount(
            handle, ctypes.byref(hndcnt))
        sys_value = hndcnt.value
        psutil_value = psutil.Process(self.pid).num_handles()
        self.assertEqual(psutil_value, sys_value) 
開發者ID:giampaolo,項目名稱:psutil,代碼行數:16,代碼來源:test_windows.py

示例12: proc_is_alive

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def proc_is_alive(pid):
        """Check if a pid is still running."""
        handle = windll.kernel32.OpenProcess(
            win32con.SYNCHRONIZE | win32con.PROCESS_QUERY_INFORMATION, 0, pid)
        if handle == 0:
            return False

        # If the process exited recently, a pid may still exist for the handle.
        # So, check if we can get the exit code.
        exit_code = DWORD()
        rval = windll.kernel32.GetExitCodeProcess(handle, byref(exit_code))
        windll.kernel32.CloseHandle(handle)
        if rval == 0: # GetExitCodeProcess failure
            raise WinError()
        return exit_code.value == win32con.STILL_ACTIVE 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:17,代碼來源:subproc.py

示例13: get_process_affinity

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def get_process_affinity(pid):
    """Return the affinity mask for the specified process."""
    flags = win32con.PROCESS_QUERY_INFORMATION
    handle = win32api.OpenProcess(flags, 0, pid)
    return win32process.GetProcessAffinityMask(handle)[0] 
開發者ID:theRealTacoTime,項目名稱:poclbm,代碼行數:7,代碼來源:guiminer.py

示例14: set_process_affinity

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def set_process_affinity(pid, mask):
    """Set the affinity for process to mask."""
    flags = win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_SET_INFORMATION
    handle = win32api.OpenProcess(flags, 0, pid)
    win32process.SetProcessAffinityMask(handle, mask) 
開發者ID:theRealTacoTime,項目名稱:poclbm,代碼行數:7,代碼來源:guiminer.py

示例15: GetProcessIdByName

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import PROCESS_QUERY_INFORMATION [as 別名]
def GetProcessIdByName(procname):
        """
        Try and get pid for a process by name.
        """

        ourPid = -1
        procname = procname.lower()

        try:
            ourPid = win32api.GetCurrentProcessId()

        except:
            pass

        pids = win32process.EnumProcesses()
        for pid in pids:
            if ourPid == pid:
                continue

            try:
                hPid = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, 0, pid)

                try:
                    mids = win32process.EnumProcessModules(hPid)
                    for mid in mids:
                        name = str(win32process.GetModuleFileNameEx(hPid, mid))
                        if name.lower().find(procname) != -1:
                            return pid

                finally:
                    win32api.CloseHandle(hPid)
            except:
                pass

        return None 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:37,代碼來源:debugger.py


注:本文中的win32con.PROCESS_QUERY_INFORMATION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。