質問

私たちはアプリケーションをVS2008からVS2010に移しています。

「属性プログラミング」を持つCOMオブジェクトを生成し、IDLは自動的に生成されます。

両方のファイルのインポート指示は異なり、コンパイルはVS2010で失敗します。

VS2008では、次のようなものを生成します。

import "docobj.idl";
.

VS 2010

import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\exdisp.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\shldisp.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\prsht.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\mshtmhst.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\mshtml.idl";
import "c:\program files (x86)\microsoft sdks\windows\v7.0a\include\dimm.idl";
import "c:\program files (x86)\microsoft sdks\windows\v7.0a\include\dispex.idl";
.

VS2010上でIDLがコンパイルされると、次のエラーが発生します。

20>  Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555 
20>  Copyright (c) Microsoft Corporation. All rights reserved.
20>  Processing .\_my_idl.idl
20>  _my_idl.idl
20>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl
20>  wincrypt.idl
20>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl(47): error MIDL2025: syntax error : expecting a type specification or a storage specifer or a type qualifier near "WCHAR"
20>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl(47): error MIDL2026: cannot recover from earlier syntax errors; aborting compilation
20>LINK : fatal error LNK1240: failed to compile IDL content
.

「wincrypt.idl」の手動削除指令はコンパイルエラーを削除しますが、IDLは自動生成されているため、ソリューションではありません。

2つのIDLが異なる理由で、インポート指示を追加する責任があるのは確かです。またはMIDLコンパイルエラーの修復方法さえ

任意のアイデア?

事前にありがとうございました。

max

役に立ちましたか?

解決

欠落

 #import "ocidl.idl"
.

コードの[IDIDL]属性を使用して修正できます。

属性プログラムはちょっとしたミスで、ATLプロジェクトウィザードのオプションとしてVS2008のオプションとして削除されたときに本質的に推奨されませんでした。あなたのコードベースの長期的なメンテナンスのためにそれを取り除くことを検討してください。自動生成された.idlは、それを開始する方法として使用できます。

他のヒント

Perhaps I was using the [importidl] attribute wrong, but I couldn't get Hans' answer to fix this problem. But the fix here worked. Just add this to the top of your stdafx.h file:

[idl_quote("import \"ocidl.idl\";")];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top