python关联通达信pywin32_Python ctypes.wintypes方法代码示例

本文整理了多个Python使用ctypes.wintypes模块与Windows系统进行交互的代码示例,包括获取窗口信息、创建链接、打开设备、操作服务等。这些示例涵盖了多种系统调用,如GetWindowThreadProcessId、CreateHardLink、OpenService等,适合需要进行系统级编程的开发者参考。
摘要由CSDN通过智能技术生成

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

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

示例1: _is_gui_available

​点赞 7

# 需要导入模块: import ctypes [as 别名]

# 或者: from ctypes import wintypes [as 别名]

def _is_gui_available():

UOI_FLAGS = 1

WSF_VISIBLE = 0x0001

class USEROBJECTFLAGS(ctypes.Structure):

_fields_ = [("fInherit", ctypes.wintypes.BOOL),

("fReserved", ctypes.wintypes.BOOL),

("dwFlags", ctypes.wintypes.DWORD)]

dll = ctypes.windll.user32

h = dll.GetProcessWindowStation()

if not h:

raise ctypes.WinError()

uof = USEROBJECTFLAGS()

needed = ctypes.wintypes.DWORD()

res = dll.GetUserObjectInformationW(h,

UOI_FLAGS,

ctypes.byref(uof),

ctypes.sizeof(uof),

ctypes.byref(needed))

if not res:

raise ctypes.WinError()

return bool(uof.dwFlags & WSF_VISIBLE)

开发者ID:war-and-code,项目名称:jawfish,代码行数:23,

示例2: get_window_thread_process_id

​点赞 6

# 需要导入模块: import ctypes [as 别名]

# 或者: from ctypes import wintypes [as 别名]

def get_window_thread_process_id(window_obj):

"""A nice wrapper for GetWindowThreadProcessId(). Returns a tuple of the

thread id (tid) of the thread that created the specified window, and the

process id that created the window.

Syntax:

DWORD GetWindowThreadProcessId(

HWND hWnd,

LPDWORD lpdwProcessId

);

Microsoft Documentation:

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowthreadprocessid

"""

pid = wintypes.DWORD()

tid = ctypes.windll.user32.GetWindowThreadProcessId(window_obj.hWnd, ctypes.byref(pid))

return tid, pid.value

开发者ID:asweigart,项目名称:nicewin,代码行数:19,

示例3: _create_windows

​点赞 6

# 需要导入模块: import ctypes [as 别名]

# 或者: from ctypes import wintypes [as 别名]

def _create_windows(source, destination, link_type):

"""Creates hardlink at destination from source in Windows."""

if link_type == HARDLINK:

import ctypes

from ctypes.wintypes import BOOL

CreateHardLink = ctypes.windll.kernel32.CreateHardLinkW

CreateHardLink.argtypes = [

ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_void_p

]

CreateHardLink.restype = BOOL

res = CreateHardLink(destination, source, None)

if res == 0:

raise ctypes.WinError()

else:

raise NotImplementedError("Link type unrecognized.")

开发者ID:getavalon,项目名称:core,代码行数:19,

示例4: open_device

​点赞 6

# 需要导入模块: import ctypes [as 别名]

# 或者: from ctypes import wintypes [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,

示例5: open_service

​点赞 6

# 需要导入模块: import ctypes [as 别名]

# 或者: from ctypes import wintypes [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.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值