I have been having a prolonged encounter with the beast known as COM Interop...
I am currently trying to generate a .tlb from a .idl file generated by the OLE/COM Object Viewer. However when trying to run Midl.exe to compile it I get an error:
.\Sim.API.IDL(236) : error MIDL2025 : syntax error : expecting a type s
pecification near "ImportFileStatus"
My .idl file is more that 1000 lines long so I don't particularly want to post it here however, I believe the Part of interest is:
typedef [uuid(980B172E-19C1-389A-BB74-29A54737C5B4), version(1.0) ,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "Sim.API.ImportFileResult")
]
struct tagImportFileResult {
ImportFileStatus _status;
LPSTR _message;
} ImportFileResult;
Then Several lines later...
typedef [uuid(A4B9A0FF-A2D4-3EC5-AB7E-69311B9122C8), version(1.0) ,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "Sim.API.ImportFileStatus")
]
enum {
ImportFileStatus_Success = 0,
ImportFileStatus_VersionMismatch = 1,
ImportFileStatus_Failure = 2
} ImportFileStatus;
I have a Feeling that these should be revered in order to fix the Type specification error. However if I do this I get a new problem.
midl\oleaut32.dll : warning MIDL2368 : error generating type library, ignored :
Could not set UUID : tagImportFileResult (0x800288C6)
I am pretty unfamiliar with the idl format and with the use of midl.exe, perhaps there is something blatantly wrong with what I am doing?
As always any help would be greatly appreciated :)
You are correct, swapping the declarations is required to keep MIDL happy. OleView.exe indeed won't generate declarations in the original order. I think it groups them by kind, the way the type lib is organized.
The message you are getting is just a warning, not an error. It is caused by having an alias for the structure name that's different. You can safely ignore it because code won't use the "tagImportFileResult" identifier. But you can get rid of it by making the tag name the same as the typedef name:
typedef [..]
struct ImportFileResult {
//...
} ImportFileResult;
Here's a KB article on the subject.
User contributions licensed under CC BY-SA 3.0