我按照 Kim Gräsman 的建议做了
https://stackoverflow.com/a/1854637/3127177
这是我的应用程序 TheServerApp 的方式:
所有已安装 Microsoft Visual Studio Community 2017
使用命令行
搜索并执行vcvars32.bat
然后执行
oleview
(如果第一次出现问题 oleview.exe 必须以管理员身份执行)
在 oleview 窗口中选择 View TypeLibs
然后打开 TheServerApp.exe
然后文件 -> 另存为
所以 IDL 定义 存储在 TheServerApp 中。idl
cd TheServerApp.IDL 所在的位置
并执行
midl TheServerApp.IDL
因为我得到了错误
TheServerApp.IDL(481) : 错误 MIDL2025 : 语法错误 : 期望“single”附近的类型规范
Client\TheServerApp.IDL(481):错误 MIDL2026:无法从早期的语法错误中恢复;中止编译
我编辑了 TheServerApp.IDL 并将所有单词都替换为 double
(见here)
现在执行midl TheServerApp**.IDL**
生成文件 TheServerApp**.tlb**
因为Visual Studio项目中的#import TheServerApp.tlb报错
在你的项目中写一个小程序imports.cpp,内容如下:
// file to import with full path
**#import** " ... /**TheServerApp.tlb**"
int main(int argc, char* argv[])
{
}
并在命令行中执行 vcvars32.bat 如上所述
执行
cl ./imports.cpp
生成 TheServerApp**.tlh** 和 TheServerApp**.tli**
在我包含的 .cpp 中
#include "./TheServerApp.tlh"
#include "./TheServerApp.tli"
我也生成了 TheServerApp.dll,但不知道是否需要进一步
tlbimp TheServerApp.tlb
哪些报告
TlbImp : 导入到 TheServerApp.dll 的类型库
所以还有文件 TheServerApp.dll
对于接下来的步骤,我必须学习更多
艾莉