0

我正在尝试在此页面中使用 IDL 生成 INetCfg 接口的类型库,如下所示:

import "netcfgx.idl";

[
        uuid(d99085ff-c5d7-4a4c-a987-91a513e268a9),
        version(1.0),
        helpstring("NetCfgX 1.0 Type Library")
]
library NetCFGLib
{
        interface IEnumNetCfgBindingInterface;
        interface IEnumNetCfgBindingPath;
        interface IEnumNetCfgComponent;
        interface INetCfg;
        interface INetCfgProperties;
        interface INetCfgLock;
        interface INetCfgBindingInterface;
        interface INetCfgBindingPath;
        interface INetCfgComponentBindings;
        interface INetCfgBindingPath;
        interface INetCfgClass;
        interface INetCfgComponent;
        interface INetCfgIdentification;
        interface INetCfgClassSetup;
};

不幸的是,生成的 IDL 仍然无法从 comtype 加载,代码如下:

        import comtypes.client as cc
        cc.GetModule("C:\path\to\netcfg.tlb")

它给出了这个错误WindowsError: [Error -2147312566] Error loading type library/DLL

如何修复此错误?我正在使用 Windows 7 64 位和 Python 27 64

4

1 回答 1

0

当我使用 Windows 7 64 位时,刚刚通过首先运行 WDK 解决了这个问题setenv.bat <path_to_wdk> x64。之后,使用midl netcfg.idl /env x64(对于 64 位 TLB)或midl netcfg.idl(对于 32 位 TLB)生成类型库。

我选择使用生成 64 位 TLB

希望它对刚刚接触到这个 COM 野兽的人有所帮助!

于 2014-04-06T22:37:38.430 回答