参考资料:

用标准C编写COM(一)COM in plain C,Part1 (http://blog.csdn.net/wangqiulin123456/article/details/8092358)

用标准C编写COM(二)COM in plain C,Part2

研究了一天,使用 vc6编译, 对VC6命令行编译配置了一下(http://blog.csdn.net/wenzhou1219/article/details/10573821),

在dos命令行使用 cl,link 最终完成了所有源代码的编译,并且生成的 com dll 能在脚本语言(vbscript, asp) 中成功调用。

 

-----------------------------------------------------------------------------

由于vc6头一回用,相关的编译命令不熟悉,查了半天资料:

编译:

cl IExample2.c /c

link /def:IExample2.def /dll IExample2.obj uuid.lib oleaut32.lib

 

//创建类型库

MIDL IExample2.idl

 


//注册 com dll

cl RegIExample2.c /c

link RegIExample2.obj user32.lib comdlg32.lib oleaut32.lib Advapi32.lib

 

 

//测试

cl IExampleApp2.c /c

link IExampleApp2.obj user32.lib uuid.lib oleaut32.lib Ole32.lib

 

-----------------------------------------------------------------------------

使用 gcc 编译:

 

//编译 com dll

gcc -shared -o IExample2.dll IExample2.c IExample2.def -luuid -loleaut32


//创建我们的类型库 (需要用到 vc6 的 MIDL)

MIDL IExample2.idl


//注册 com dll
gcc -o RegIExample2.exe RegIExample2.c -lcomdlg32 -loleaut32

 

//测试
gcc -o IExampleApp2.exe IExampleApp2.c -luuid -loleaut32 -lOle32

 

-----------------------------------------------------------------------------

 

最后,关于在 vbscript 中调用的时候,必需:IExample2.tlb (通过 MIDL IExample2.idl 生成的)

网上说可以将 tlb 文件嵌入到 dll 文件中,但操作上似乎有点复杂,一时没解决。

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2021-08-10
  • 2022-12-23
  • 2021-10-16
  • 2021-10-19
  • 2022-12-23
  • 2021-07-29
猜你喜欢
  • 2021-10-29
  • 2021-10-08
  • 2022-02-15
相关资源
相似解决方案