当前位置: 首页>>代码示例>>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;未经允许,请勿转载。