mirror of
https://github.com/yv1ing/ShotRDP.git
synced 2025-09-16 15:10:57 +08:00
加入Python调用DLL模块
This commit is contained in:
31
gui/main.py
Normal file
31
gui/main.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import ctypes
|
||||||
|
|
||||||
|
|
||||||
|
def shot(target, width, height):
|
||||||
|
lib = ctypes.CDLL('../shotrdp.dll')
|
||||||
|
|
||||||
|
lib.GetScreen.argtypes = [
|
||||||
|
ctypes.c_char_p,
|
||||||
|
ctypes.POINTER(ctypes.POINTER(ctypes.c_char)),
|
||||||
|
ctypes.POINTER(ctypes.c_int),
|
||||||
|
ctypes.c_int,
|
||||||
|
ctypes.c_int,
|
||||||
|
]
|
||||||
|
lib.GetScreen.restype = ctypes.c_char_p
|
||||||
|
|
||||||
|
data = ctypes.POINTER(ctypes.c_char)()
|
||||||
|
length = ctypes.c_int()
|
||||||
|
|
||||||
|
error_ptr = lib.GetScreen(target, ctypes.byref(data), ctypes.byref(length), width, height)
|
||||||
|
if error_ptr:
|
||||||
|
print(ctypes.string_at(error_ptr).decode())
|
||||||
|
else:
|
||||||
|
result = ctypes.string_at(data, length.value)
|
||||||
|
with open('test.png', 'wb') as f:
|
||||||
|
f.write(result)
|
||||||
|
|
||||||
|
lib.Free(data)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
shot(b'127.0.0.1:3389', 1024, 800)
|
||||||
Reference in New Issue
Block a user