2012-04-24 36 views
0

我有一個非常簡單的C++/CLI窗口窗體程序,100%正常工作。如何在VC++中正確包含.h文件?

由於我想添加呼叫Internet Explorer,當我單擊窗口窗體上的按鈕時,我添加了「一行代碼」用於測試目的。

我添加的#include 「Shellapi.h」的#pragma一次。之後,VS給了我500行的錯誤信息。

我的問題是,我只是添加一個.h文件到我的程序。爲什麼會造成任何問題?我想念什麼?

===========錯誤消息===============

1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(56): error C2065: 'HDROP' : undeclared identifier 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(56): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT' 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C2146: syntax error : missing ';' before identifier 'UINT' 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE' 
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Shellapi.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
+0

如果您可以在這裏包含前幾行錯誤,那可能會幫助您獲得解決方案。這真的是C++/CLI嗎? – 2012-04-24 17:44:01

+0

@SteveTownsend你是對的,我應該把更多的信息。我在做C++/CLI – user765168 2012-04-24 17:52:13

回答

3

幾件事情:

  1. 您應該#include <windows.h>在任何Windows程序

  2. 您應該包括任何系統文件 - 像shellapi.h - 用括號(<>)而不是引號("")例如#include <shellapi.h>

  3. 如果您從命令行進行編譯,最好運行「vcvars32.bat」(或等效命令)爲Visual Studio設置命令行環境。

0

的前幾行,我相信你忘了#include <windows.h>#include <shellapi.h>

一般(或至少在我的個人經驗),當你包含一個頭,你缺失<windows.h>或其他一些標題後錯誤的牆上轟炸。