2012-04-24 132 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>或其他一些标题后错误的墙上轰炸。

相关问题