MENU

Python调用大漠插件

March 19, 2020 • Read: 2458 • Python阅读设置

注册大漠插件

安装 pypiwin32

import os
import win32com.client

os.system("regsvr32 D:/dm.dll /s")
dm = win32com.client.Dispatch("dm.dmsoft")

print(dm.ver())

要使用 32 位的 Python!!!

免注册大漠插件

研究了很久不成功,存档······

import ctypes
from comtypes.client import CreateObject
dms = ctypes.windll.LoadLibrary(r'DmReg.dll')
dms.SetDllPathW(r'dm.dll', 0)
dm = CreateObject('dm.dmsoft')
print(dm.Ver())
Last Modified: May 26, 2021
Leave a Comment

4 Comments
  1. 1 1

    run as administrator

    1. 1 1

      @1没用

  2. a a

    解决没~

  3. 波克捕鱼 波克捕鱼

    from ctypes import WinDLL
    from win32com.client import Dispatch
    import os

    G_sGlobalPath = os.getcwd()
    print(G_sGlobalPath)

    dll = WinDLL(G_sGlobalPath + '\DmReg.dll')
    dll.SetDllPathW(G_sGlobalPath + '\dm.dll', 0)
    dm = Dispatch('dm.dmsoft')
    dm_Ver = dm.Ver()
    print(dm_Ver)

    这代码可用, 免注册文件和dm主体放在和pycharm 文件同一个文件夹里,