当前位置: 首页>>代码示例>>Python>>正文


Python wintypes.DWORD属性代码示例

本文整理汇总了Python中ctypes.wintypes.DWORD属性的典型用法代码示例。如果您正苦于以下问题:Python wintypes.DWORD属性的具体用法?Python wintypes.DWORD怎么用?Python wintypes.DWORD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ctypes.wintypes的用法示例。


在下文中一共展示了wintypes.DWORD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: try_enable_ansi

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def try_enable_ansi():
            """Try enabling ANSI colors
            https://stackoverflow.com/questions/44482505/setconsolemode-returning-false-when-enabling-ansi-color-under-windows-10"""
            lpMode = wintypes.DWORD()
            handle = WINAPI._GetStdHandle(WINAPI._STDOUT)
            if WINAPI._GetConsoleMode(handle, ctypes.byref(lpMode)):
               
                if not WINAPI._SetConsoleMode(handle, lpMode.value | WINAPI._ENABLE_VIRTUAL_TERMINAL_PROCESSING):
                    return False
            else:
                return False
            
            lpMode = wintypes.DWORD()
            handle = WINAPI._GetStdHandle(WINAPI._STDERR)
            if WINAPI._GetConsoleMode(handle, ctypes.byref(lpMode)):
                if not WINAPI._SetConsoleMode(handle, lpMode.value | WINAPI._ENABLE_VIRTUAL_TERMINAL_PROCESSING):
                    return False
            else:
                return False
            
            return True 
开发者ID:mme,项目名称:vergeml,代码行数:23,代码来源:display.py

示例2: CoInitializeEx

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def CoInitializeEx(reserved, co_init):
    prototype = ctypes.WINFUNCTYPE(
        HRESULT,
        wintypes.LPVOID,
        wintypes.DWORD
    )

    paramflags = (
        (_In_, 'pvReserved'),
        (_In_, 'dwCoInit')
    )

    _CoInitializeEx = prototype(('CoInitializeEx', ole32), paramflags)
    _CoInitializeEx.errcheck = RAISE_NON_ZERO_ERR

    return _CoInitializeEx(reserved, co_init) 
开发者ID:fireeye,项目名称:cWMI,代码行数:18,代码来源:winapi.py

示例3: CoCreateInstance

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def CoCreateInstance(clsid, unk, ctx, iid):
    prototype = ctypes.WINFUNCTYPE(
        HRESULT,
        ctypes.POINTER(GUID),
        wintypes.LPVOID,
        wintypes.DWORD,
        ctypes.POINTER(GUID),
        ctypes.POINTER(wintypes.LPVOID)
    )

    paramflags = (
        (_In_, 'rclsid'),
        (_In_, 'pUnkOuter'),
        (_In_, 'dwClsContext'),
        (_In_, 'riid'),
        (_Out_, 'ppv')
    )

    _CoCreateInstance = prototype(('CoCreateInstance', ole32), paramflags)
    _CoCreateInstance.errcheck = RAISE_NON_ZERO_ERR
    return _CoCreateInstance(clsid, unk, ctx, iid) 
开发者ID:fireeye,项目名称:cWMI,代码行数:23,代码来源:winapi.py

示例4: get_printer_names

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def get_printer_names():
    names = []
    info = ctypes.POINTER(BYTE)()
    pcbNeeded = DWORD(0)
    pcReturned = DWORD(0)
    winspool.EnumPrintersW(PRINTER_ENUM_LOCAL, NAME, 1, ctypes.byref(info),
                           0, ctypes.byref(pcbNeeded), ctypes.byref(pcReturned))
    bufsize = pcbNeeded.value
    if bufsize:
        buff = msvcrt.malloc(bufsize)
        winspool.EnumPrintersW(PRINTER_ENUM_LOCAL, NAME, 1, buff, bufsize,
                               ctypes.byref(pcbNeeded),
                               ctypes.byref(pcReturned))
        info = ctypes.cast(buff, ctypes.POINTER(PRINTER_INFO_1))
        for i in range(pcReturned.value):
            names.append(info[i].pName)
        msvcrt.free(buff)
    return names 
开发者ID:sk1project,项目名称:sk1-wx,代码行数:20,代码来源:winspool.py

示例5: is_color_printer

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def is_color_printer(prtname):
    ret = False
    if not prtname:
        prtname = get_default_printer()
    hptr = open_printer(prtname)
    info = ctypes.POINTER(BYTE)()
    cbBuf = DWORD(0)
    pcbNeeded = DWORD(0)
    winspool.GetPrinterA(hptr, 2, ctypes.byref(info),
                         cbBuf, ctypes.byref(pcbNeeded))
    bufsize = pcbNeeded.value
    if bufsize:
        buff = msvcrt.malloc(bufsize)
        winspool.GetPrinterA(hptr, 2, buff, bufsize, ctypes.byref(pcbNeeded))
        info = ctypes.cast(buff, ctypes.POINTER(PRINTER_INFO_2))
        ret = info.contents.pDevMode.contents.dmColor == 2
        msvcrt.free(buff)
    close_printer(hptr)
    return ret 
开发者ID:sk1project,项目名称:sk1-wx,代码行数:21,代码来源:winspool.py

示例6: enum_process_names

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def enum_process_names():
	pid_to_name = {}
	
	for pid in enum_pids():
		pid_to_name[pid] = 'Not found'
		process_handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, False, pid)
		if process_handle is None:
			logging.debug('[Enum Processes]Failed to open process PID: %d Reason: %s ' % (pid, WinError(get_last_error())))
			continue
		
		image_name = (ctypes.c_char*MAX_PATH)()
		max_path = DWORD(4096)
		#res = GetProcessImageFileName(process_handle, image_name, MAX_PATH)
		res = QueryFullProcessImageName(process_handle, 0 ,image_name, ctypes.byref(max_path))
		if res == 0:
			logging.debug('[Enum Proceses]Failed GetProcessImageFileName on PID: %d Reason: %s ' % (pid, WinError(get_last_error())))
			continue
		
		pid_to_name[pid] = image_name.value.decode()
	return pid_to_name 
开发者ID:skelsec,项目名称:minidump,代码行数:22,代码来源:createminidump.py

示例7: open_device

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def open_device(self, access=GENERIC_READ | GENERIC_WRITE, mode=0, creation=OPEN_EXISTING, flags=FILE_ATTRIBUTE_NORMAL):
        """See: CreateFile function
        http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx
        """
        CreateFile_Fn = ctypes.windll.kernel32.CreateFileA
        CreateFile_Fn.argtypes = [
                wintypes.LPCSTR,                    # _In_          LPCTSTR lpFileName
                wintypes.DWORD,                     # _In_          DWORD dwDesiredAccess
                wintypes.DWORD,                     # _In_          DWORD dwShareMode
                LPSECURITY_ATTRIBUTES,              # _In_opt_      LPSECURITY_ATTRIBUTES lpSecurityAttributes
                wintypes.DWORD,                     # _In_          DWORD dwCreationDisposition
                wintypes.DWORD,                     # _In_          DWORD dwFlagsAndAttributes
                wintypes.HANDLE]                    # _In_opt_      HANDLE hTemplateFile
        CreateFile_Fn.restype = wintypes.HANDLE

        
        self.handle = wintypes.HANDLE(CreateFile_Fn('\\\\.\\' + self.name,
                             access,
                             mode,
                             NULL,
                             creation,
                             flags,
                             NULL)) 
开发者ID:FSecureLABS,项目名称:win_driver_plugin,代码行数:25,代码来源:driverlib.py

示例8: open_service

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def open_service(service_manager_handle, service_name, desired_access):
	""" See: OpenService function
	https://msdn.microsoft.com/en-us/library/windows/desktop/ms684330(v=vs.85).aspx
	"""
	OpenService_Fn = ctypes.windll.Advapi32.OpenServiceA 	#SC_HANDLE WINAPI OpenService(
	OpenService_Fn.argtypes = [						#
		wintypes.HANDLE,							#	_In_ SC_HANDLE hSCManager,
		LPCTSTR,							#	_In_ LPCTSTR   lpServiceName,
		wintypes.DWORD								#	_In_ DWORD     dwDesiredAccess
	]
	OpenService_Fn.restype = wintypes.SC_HANDLE
	handle = OpenService_Fn(
		service_manager_handle,
		service_name,
		desired_access
	)
	return handle 
开发者ID:FSecureLABS,项目名称:win_driver_plugin,代码行数:19,代码来源:driverlib.py

示例9: open_sc_manager

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def open_sc_manager(machine_name, database_name, desired_access):
	"""See: OpenSCManager function
	https://msdn.microsoft.com/en-us/library/windows/desktop/ms684323(v=vs.85).aspx
	"""
	OpenSCManager_Fn = ctypes.windll.Advapi32.OpenSCManagerA	#SC_HANDLE WINAPI OpenSCManager(
	OpenSCManager_Fn.argtypes = [						#
		LPCTSTR,								#	_In_opt_ LPCTSTR lpMachineName,
		LPCTSTR,								#	_In_opt_ LPCTSTR lpDatabaseName,
		wintypes.DWORD									#	_In_     DWORD   dwDesiredAccess
	]
	OpenSCManager_Fn.restype = wintypes.SC_HANDLE
	handle = OpenSCManager_Fn(
		machine_name,
		database_name,
		desired_access
	)
	return handle 
开发者ID:FSecureLABS,项目名称:win_driver_plugin,代码行数:19,代码来源:driverlib.py

示例10: start_service

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def start_service(service_handle, service_arg_count, service_arg_vectors):
	"""See: StartService function
	https://msdn.microsoft.com/en-us/library/windows/desktop/ms686321(v=vs.85).aspx
	"""
	
	StartService_Fn = ctypes.windll.Advapi32.StartServiceA	#BOOL WINAPI StartService(
	StartService_Fn.argtypes = [					#
		wintypes.SC_HANDLE,							#	_In_ 	 SC_HANDLE hService,
		wintypes.DWORD,								#	_In_ 	 DWORD     dwNumServiceArgs,
		LPCTSTR							#	_In_opt_ LPCTSTR   *lpServiceArgVectors
	]
	StartService_Fn.restype = wintypes.BOOL
	bool = StartService_Fn(
		service_handle,
		service_arg_count, 
		service_arg_vectors
	)
	return bool 
开发者ID:FSecureLABS,项目名称:win_driver_plugin,代码行数:20,代码来源:driverlib.py

示例11: WlanOpenHandle

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def WlanOpenHandle():
    """
        The WlanOpenHandle function opens a connection to the server.

        DWORD WINAPI WlanOpenHandle(
            _In_        DWORD dwClientVersion,
            _Reserved_  PVOID pReserved,
            _Out_       PDWORD pdwNegotiatedVersion,
            _Out_       PHANDLE phClientHandle
        );
    """
    func_ref = wlanapi.WlanOpenHandle
    func_ref.argtypes = [DWORD, c_void_p, POINTER(DWORD), POINTER(HANDLE)]
    func_ref.restype = DWORD
    negotiated_version = DWORD()
    client_handle = HANDLE()
    result = func_ref(2, None, byref(negotiated_version), byref(client_handle))
    if result != ERROR_SUCCESS:
        raise Exception("WlanOpenHandle failed.")
    return client_handle 
开发者ID:kedos,项目名称:win32wifi,代码行数:22,代码来源:Win32NativeWifiApi.py

示例12: WlanCloseHandle

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def WlanCloseHandle(hClientHandle):
    """
        The WlanCloseHandle function closes a connection to the server.

        DWORD WINAPI WlanCloseHandle(
            _In_        HANDLE hClientHandle,
            _Reserved_  PVOID pReserved
        );
    """
    func_ref = wlanapi.WlanCloseHandle
    func_ref.argtypes = [HANDLE, c_void_p]
    func_ref.restype = DWORD
    result = func_ref(hClientHandle, None)
    if result != ERROR_SUCCESS:
        raise Exception("WlanCloseHandle failed.")
    return result 
开发者ID:kedos,项目名称:win32wifi,代码行数:18,代码来源:Win32NativeWifiApi.py

示例13: WlanEnumInterfaces

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def WlanEnumInterfaces(hClientHandle):
    """
        The WlanEnumInterfaces function enumerates all of the wireless LAN
        interfaces currently enabled on the local computer.

        DWORD WINAPI WlanEnumInterfaces(
            _In_        HANDLE hClientHandle,
            _Reserved_  PVOID pReserved,
            _Out_       PWLAN_INTERFACE_INFO_LIST *ppInterfaceList
        );
    """
    func_ref = wlanapi.WlanEnumInterfaces
    func_ref.argtypes = [HANDLE,
                         c_void_p,
                         POINTER(POINTER(WLAN_INTERFACE_INFO_LIST))]
    func_ref.restype = DWORD
    wlan_ifaces = pointer(WLAN_INTERFACE_INFO_LIST())
    result = func_ref(hClientHandle, None, byref(wlan_ifaces))
    if result != ERROR_SUCCESS:
        raise Exception("WlanEnumInterfaces failed.")
    return wlan_ifaces 
开发者ID:kedos,项目名称:win32wifi,代码行数:23,代码来源:Win32NativeWifiApi.py

示例14: WlanDeleteProfile

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def WlanDeleteProfile(hClientHandle, pInterfaceGuid, profileName):
    """
    DWORD WINAPI WlanDeleteProfile(
        _In_             HANDLE  hClientHandle,
        _In_       const GUID    *pInterfaceGuid,
        _In_             LPCWSTR strProfileName,
        _Reserved_       PVOID   pReserved
    );
    """
    func_ref = wlanapi.WlanDeleteProfile
    func_ref.argtypes = [HANDLE,
                         POINTER(GUID),
                         LPCWSTR,
                         c_void_p]
    func_ref.restype = DWORD
    result = func_ref(hClientHandle,
                      byref(pInterfaceGuid),
                      profileName,
                      None)
    if result != ERROR_SUCCESS:
        raise Exception("WlanDeleteProfile failed. error %d" % result, result)
    return result 
开发者ID:kedos,项目名称:win32wifi,代码行数:24,代码来源:Win32NativeWifiApi.py

示例15: WlanConnect

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import DWORD [as 别名]
def WlanConnect(hClientHandle, pInterfaceGuid, pConnectionParameters):
    """
    The WlanConnect function attempts to connect to a specific network.

    DWORD WINAPI WlanConnect(
            _In_        HANDLE hClientHandle,
            _In_        const GUID *pInterfaceGuid,
            _In_        const PWLAN_CONNECTION_PARAMETERS pConnectionParameters,
            _Reserved_  PVOID pReserved
    );
    """
    func_ref = wlanapi.WlanConnect
    func_ref.argtypes = [HANDLE,
                         POINTER(GUID),
                         POINTER(WLAN_CONNECTION_PARAMETERS),
                         c_void_p]
    func_ref.restype = DWORD
    result = func_ref(hClientHandle,
                      pointer(pInterfaceGuid),
                      pointer(pConnectionParameters),
                      None)
    if result != ERROR_SUCCESS:
        raise Exception("".join(["WlanConnect failed with error ", str(result)]))
    return result 
开发者ID:kedos,项目名称:win32wifi,代码行数:26,代码来源:Win32NativeWifiApi.py


注:本文中的ctypes.wintypes.DWORD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。