Syntax error while converting IDL to C header

别等时光非礼了梦想. 提交于 2019-12-12 11:46:02

问题


I am trying to get C header files for COM interfaces using OLE/COM object viewer.

I have tries to save type library as header file in object viewer, however, after a cmd window flashes, nothing happens. I have tried to save it as IDL file and convert to header file myself using this command;

midl /out C:\temp /header EXCEL.h EXCEL.IDL

However, I am getting this error:

Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
64 bit Processing .\EXCEL.IDL
EXCEL.IDL
64 bit Processing C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\oaidl.idl

oaidl.idl
64 bit Processing C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\objidl.id
l
objidl.idl
64 bit Processing C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\unknwn.id
l
unknwn.idl
64 bit Processing C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\wtypes.id
l
wtypes.idl
64 bit Processing C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\basetsd.h

basetsd.h
64 bit Processing C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\guiddef.h

guiddef.h
.\EXCEL.IDL(17) : warning MIDL2015 : failed to load tlb in importlib: : VBE6EXT.
OLB
.\EXCEL.IDL(19) : warning MIDL2015 : failed to load tlb in importlib: : MSO.DLL
.\EXCEL.IDL(629) : error MIDL2025 : syntax error : expecting a type specificatio
n near "single"
.\EXCEL.IDL(629) : error MIDL2026 : cannot recover from earlier syntax errors; a
borting compilation

VBE6EXT.OLB file can be found in C:\Program Files (x86)\Common Files\microsoft shared\VBA\VBA6, MSO.dll file can be found at C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12

There are the lines that warnings and errors happen:

  1. importlib("VBE6EXT.OLB");
  2. --
  3. importlib("MSO.DLL");

--

  1. HRESULT Item(
  2. [in] int Index,
  3. [out, retval] single* Val);

My guess is that I need to tell midl to where to find those two missing files, but I don't know how to do that.

Edit:

I have updated the compiler command like this:

midl /out C:\temp /header EXCEL.h /I "C:\Program Files (x86)\Common Files\microsoft shared\VBA\VBA6;C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12" EXCEL.IDL

It fixes the failed to load warnings but syntax error still persists. midl doesnt recognize single as a type. Am I missing something here?

来源:https://stackoverflow.com/questions/33065999/syntax-error-while-converting-idl-to-c-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!