我用这个打了一堵墙.我需要创建一个基于python的com服务器,将其打包为windows exe并将其部署在Windows上.它必须具有"完整"接口 - 因为消费者需要idispatch和特定的interfce才能运行.现在我已经创建了com服务器并让它在解释器下运行,并且它与我挑剔的客户端完美地运行.但是,当打包为EXE时 - 它是一个本地服务器 - 当系统尝试实例化时,我在日志中出现错误(即使是从vbs脚本).所以这里的每一个.我在itnernet中搜索高低,它看起来像一个导入问题,但我不知道如何导入我自己的python对象供本地服务器使用.
这是安装了pywin32扩展的python 2.7.
首先 - 我为服务器创建的IDL:
imtg.idl
// This file will be processed by the MIDL tool to
// produce the type library (imtg.tlb) and marshalling code.
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(4fafbb23-6a38-4613-b93b-68ea66c67043),
dual,
helpstring("IImtGroupApp Interface"),
pointer_default(unique)
]
interface IImtGroupApp : IDispatch
{
[id(1), helpstring("method EchoString")] HRESULT EchoString([in] BSTR in1, [out, retval] BSTR *vals);
[id(2), helpstring("method AddNumbers")] HRESULT AddNumbers([in] long in1, [in] long in2, [out, retval] long *vali);
};
[
uuid(d665e9d0-71a9-4e23-a1b4-abe3376d5c58),
version(1.0), …Run Code Online (Sandbox Code Playgroud)