線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1997
推到 Plurk!
推到 Facebook!

SHBrowseForFolder編譯錯誤

答題得分者是:RaynorPao
JosephLiu77
一般會員


發表:11
回覆:8
積分:3
註冊:2003-02-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-03-02 00:52:55 IP:211.76.xxx.xxx 未訂閱
我在BCB寫了一些程式碼... #include "shlobj.h" ................... BROWSEINFO bi={0}; bi.lpszTitle="Pick a Directory"; LPITEMIDLIST pidl=SHBrowseForFolder(&bi); 結果在編譯的時候,竟然會產生錯誤 shobjidl.h(2193): E2238 Multiple declaration for 'FOLDERSETTING' shobjidl.h(8095): E2238 Multiple declaration for 'DESKBANDINFO' shobjidl.h(1422): E2238 Multiple declaration for 'FVSHOWINFO' shobjidl.h(3457): E2238 Multiple declaration for 'SHELLFAGSTATE' 為什麼會這樣子? 請大大幫幫忙...謝謝
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-03-02 00:54:48 IP:61.221.xxx.xxx 未訂閱
引言: 我在BCB寫了一些程式碼... #include "shlobj.h" ................... BROWSEINFO bi={0}; bi.lpszTitle="Pick a Directory"; LPITEMIDLIST pidl=SHBrowseForFolder(&bi); 結果在編譯的時候,竟然會產生錯誤 shobjidl.h(2193): E2238 Multiple declaration for 'FOLDERSETTING' shobjidl.h(8095): E2238 Multiple declaration for 'DESKBANDINFO' shobjidl.h(1422): E2238 Multiple declaration for 'FVSHOWINFO' shobjidl.h(3457): E2238 Multiple declaration for 'SHELLFAGSTATE' 為什麼會這樣子? 請大大幫幫忙...謝謝 < face="Verdana, Arial, Helvetica"> JosephLiu77 你好: 請參考以下的連結文章
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
JosephLiu77
一般會員


發表:11
回覆:8
積分:3
註冊:2003-02-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-03-02 01:00:51 IP:211.76.xxx.xxx 未訂閱
真的可以了...應該早一點來問的,謝謝版主
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-03-02 10:12:39 IP:218.173.xxx.xxx 未訂閱
http://www.bcbdev.com/faqs/faq91.htm 整理:    Q: Fix compiler errors in shellapi.h or shlobj.h    Answer You may encounter compiler errors in the API header files shellapi.h and shlobj.h if you try to include them from a BCB5 VCL program. The problem is caused by conflicts between the API header files, and the VCL header files shlobj.hpp and shellapi.hpp. The HPP version of the files exist for the sake of other VCL headers (ie you should never need to include shlobj.hpp or shellapi.hpp in your code).     The solution to shellapi.h and shlobj.h compiler errors is to globally define the constant NO_WIN32_LEAN_AND_MEAN in your project. You can do this in the IDE from the Directories/Conditionals tab of the project options dialog. Enter NO_WIN32_LEAN_AND_MEAN in the Conditional Defines box. If you have multiple defines listed, you can separate them with semicolons.     If you compile from the commandline, you can define NO_WIN32_LEAN_AND_MEAN inside your makefile, or by passing it to make with the -D switch. You can also use the -D switch if you compile directly with bcc32. You might be tempted to define NO_WIN32_LEAN_AND_MEAN by placing a #define statement right in the source file that needs shlobj.h or shellapi.h. Like this:

#include < vcl.h >
#pragma hdrstop    #define NO_WIN32_LEAN_AND_MEAN
#include < shellapi.h >
Unfortunately, this won't help. NO_WIN32_LEAN_AND_MEAN must be defined before you include vcl.h. To understand why, look at the files vcl0.h and shlobj.hpp. Since NO_WIN32_LEAN_AND_MEAN must be defined before including vcl.h, you could try this:

#define NO_WIN32_LEAN_AND_MEAN
#include < vcl.h >
#pragma hdrstop    #include < shellapi.h >
This will solve the compiler errors, but it will also disrupt your use of precompiled header files. As a result, your project will take longer to compile. For information on why, see the article on precompiled header use. Since you can't use a local #define to solve the problem, you are forced to define NO_WIN32_LEAN_AND_MEAN globally in your project options or makefile. While this will solve your problems regarding shlobj.h, it does come at a cost. Defining NO_WIN32_LEAN_AND_MEAN forces vcl0.h not to define WIN32_LEAN_AND_MEAN (note the missing NO_). WIN32_LEAN_AND_MEAN affects how many header files are pulled in when you include windows.h. If WIN32_LEAN_AND_MEAN is defined, fewer API header files are included (see windows.h to understand why). Defining NO_WIN32_LEAN_AND_MEAN prevents the definition of WIN32_LEAN_AND_MEAN, which in turn causes more API header files to be pulled in when windows.h is included (windows.h is included by all VCL apps via sysmac.h). These extra header files usually aren't necessary, and may increase your compile times slightly. Otherwise, the extra header files shouldn't cause any problems.
系統時間:2024-04-19 20:18:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!