在Python中可以方便地使用os模块运行其他的脚本或者程序,这样就可以在脚本中直接使用其他脚本,或者程序提供的功能,而不必再次编写实现该功能的代码。
为了更好地控制运行的进程,可以使用win32process模块中的函数。
如果想进一步控制进程,则可以使用ctype模块,直接调用kernel32.dll中的函数。
不知道你具体是什么问题,下面是python调用win msgbox 和shellexec的方法,可以参考一下:
import ctypes#win api shellexecuteapiA and msgboxA
def execute(path):
handler = None
operator = "open"
fpath = path
param = None
dirpath = None
ncmd = 1
shell32 = ctypes.windll.LoadLibrary("shell32.dll")
shell32.ShellExecuteA(handler,operator,fpath,param,dirpath,ncmd)
def msgbox(msg='mesage'):
user32 = ctypes.windll.LoadLibrary('user32.dll')
user32.MessageBoxA(0, msg.decode('utf8').encode('gbk'), 'aaaaaaa',0)
if __name__ == '__main__':
execute('config.ini')
msgbox('aaaaaa')
参考地址:http://www.pubwin2009.net/index.php/python/27.html
首先要把类操作用c语言包装一遍,再用python的API包装一个模块出来(以上两个都是c,不是c++),编译的时候编译成特殊的动态链接库,在python里面import当成普通模块调用具体太复杂,自己找教程和api吧