!!!注意必须要Python32位版本的!!!
1. 使用国内镜像安装pywin32--225版本的包,大于255版本会报错
pip install pywin32==225 -i https://pypi.tuna.tsinghua.edu.cn/simple
2. 调试Python
import os
from win32com.client import Dispatch
from ctypes import WinDLL
class Desert:
# 免注册大漠
def __init__(self, dm_dll, dm_reg):
self.dm = None
dll = WinDLL(dm_reg)
dll.SetDllPathW(dm_dll, 1)
# 注册大漠
@staticmethod
def fn_register(dm_dll):
os.system("regsvr32 " + dm_dll + " /s")
# 创建大漠
def fn_establish(self):
self.dm = Dispatch('dm.dmsoft')
g_desert = Desert(os.getcwd() + '\dm.dll', os.getcwd() + '\DmReg.dll')
g_desert.fn_establish() # 创建大漠对象
reg_code = "3123123f2f8b37f2206acd5f73a4a751c5ce2e" # 大漠后台的注册码
ver_info = '1233'
if g_desert.dm.Reg(reg_code, ver_info) == 1:
print('大漠注册成功')
print('插件版本:' + str(g_desert.dm.Ver()))
else:
print('大漠注册失败')