全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3341
推到 Plurk!
推到 Facebook!

IShellView, IShellFolder..etc的使用問題

尚未結案
lcsboy
版主


發表:87
回覆:622
積分:394
註冊:2002-06-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-10-16 01:32:55 IP:210.85.xxx.xxx 未訂閱
查了查SDK 有IShellView, IShellFolder, IShellLink....etc 這些只些著Interface的東東, 很像Class, 又不知如何繼承 怎麼使用呀? 而且在ShlObj.h裡面好像都有 但是不管怎麼include都會出現error -> muticlare
RaynorPao
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-10-16 09:56:53 IP:203.73.xxx.xxx 未訂閱
引言: 查了查SDK 有IShellView, IShellFolder, IShellLink....etc 這些只些著Interface的東東, 很像Class, 又不知如何繼承 怎麼使用呀? 而且在ShlObj.h裡面好像都有 但是不管怎麼include都會出現error -> muticlare < face="Verdana, Arial, Helvetica"> 如果你有安裝 Platform SDK 的話 在 ..\Program Files\Microsoft SDK\Samples\Web\bits\bits_ie 目錄下~~有 IShellLink 的 sample code 至於你說 compile 會有錯誤發生?? 我的不會耶
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
RaynorPao
版主


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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-10-16 10:07:02 IP:203.73.xxx.xxx 未訂閱
引言: 查了查SDK 有IShellView, IShellFolder, IShellLink....etc 這些只些著Interface的東東, 很像Class, 又不知如何繼承 怎麼使用呀? 而且在ShlObj.h裡面好像都有 但是不管怎麼include都會出現error -> muticlare < face="Verdana, Arial, Helvetica"> 在 ..\Program Files\Microsoft SDK\Samples\WinUI\Shell\SampView 目錄下~~有 IShellFolder 的 sample code
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
lcsboy
版主


發表:87
回覆:622
積分:394
註冊:2002-06-18

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-10-16 12:56:22 IP:210.63.xxx.xxx 未訂閱
Sample是找到了, 但是是For VC 的 有BCB的code嗎? 還是BCB怎麼把VC 的東東加進來用呢?
jackkcg
站務副站長


發表:891
回覆:1050
積分:848
註冊:2002-03-23

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-10-16 13:05:55 IP:61.221.xxx.xxx 未訂閱
參考看看 L sir C Builder 3.0下編譯含有MFC的程式 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=21592 Visual C DLLs in a C Builder Project http://delphi.ktop.com.tw/topic.php?TOPIC_ID=18754 http://trans.myany.com/trans/tw/Trans.asp?URL=http://homepage1.nifty.com/kotobukijirushi/bcbonsun/bosvol06.html&ToLanguage=0 發表人 - jackkcg 於 2002/10/16 13:17:15
------
**********************************************************
哈哈&兵燹
最會的2大絕招 這個不會與那個也不會 哈哈哈 粉好

Delphi K.Top的K.Top分兩個字解釋Top代表尖端的意思,希望本討論區能提供Delphi的尖端新知
K.表Knowlege 知識,就是本站的標語:Open our mind
RaynorPao
版主


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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-10-17 08:42:26 IP:203.73.xxx.xxx 未訂閱
引言: Sample是找到了, 但是是For VC 的 有BCB的code嗎? 還是BCB怎麼把VC 的東東加進來用呢?
嗯~~ 你也不必把整個 Sample code 的專案移到 bcb 的 project 只要把你所需要的部分~~移到 bcb 的 project 中 然後再 include 相關的 *.h, *.lib 就可以了 這就是典型的 Win32 API 與 C Builder 整合的例子 而且~~我覺得這是有必要的 因為~~有的時候 C Builder 所提供的做法 並不一定能夠滿足 project 的需求 因此~~就必須要更具有彈性的做法 另外一點~~如果只需要使用 Win32 API 或者是某某 COM 物件的話 並不會跟 MFC 扯上關係的 當然~~最好不要扯上(不然~~麻煩死了)
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
lcsboy
版主


發表:87
回覆:622
積分:394
註冊:2002-06-18

發送簡訊給我
#7 引用回覆 回覆 發表時間:2002-10-17 20:45:53 IP:210.85.xxx.xxx 未訂閱
有沒有範例呀? 還是可以麻煩你寫一個? 讓大家都能共享一下呢? 對了, 我的> 一定會有幾個
RaynorPao
版主


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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2002-10-18 09:10:17 IP:203.73.xxx.xxx 未訂閱
引言: 有沒有範例呀? 還是可以麻煩你寫一個? 讓大家都能共享一下呢? 對了, 我的> 一定會有幾個>< face="Verdana, Arial, Helvetica"> 範例~~就在樓上敘述的那些位置 因為~~我也沒有用過~~我只知道那麼多 不過~~我已經試過 compiler 了 我是使用 Bcb6(以 IShellLink 為例) 在你的 Unit1.h #include "shobjidl.h" 然後在 Unit1.cpp 中加入以下程式碼
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   IShellLink *pShlLink=NULL;
   .........................
   if(pShlLink) pShlLink->Release();
}
備註:如果 compile 會發生錯誤的話 就先把 shobjidl.h 中會產生宣告錯誤的 struct 給 mark 掉
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
turboted
版主


發表:95
回覆:754
積分:452
註冊:2002-07-23

發送簡訊給我
#9 引用回覆 回覆 發表時間:2002-10-19 23:41:14 IP:61.216.xxx.xxx 未訂閱
參考 http://www.bcbdev.com/faqs/faq62.htm #include  void __fastcall TForm1::Button1Click(TObject *Sender) { BROWSEINFO info; char szDir[MAX_PATH]; char szDisplayName[MAX_PATH]; LPITEMIDLIST pidl; LPMALLOC pShellMalloc; // SHBrowseForFolder returns a PIDL. The memory for the PIDL is // allocated by the shell. Eventually, we will need to free this // memory, so we need to get a pointer to the shell malloc COM // object that will free the PIDL later on. if(SHGetMalloc(&pShellMalloc) == NO_ERROR) { // if we were able to get the shell malloc object, // then proceed by initializing the BROWSEINFO stuct memset(&info, 0x00,sizeof(info)); info.hwndOwner = Handle; // Owner window info.pidlRoot = 0; // root folder info.pszDisplayName = szDisplayName; // return display name info.lpszTitle = "Browse Title"; // label caption info.ulFlags = BIF_RETURNONLYFSDIRS; // config flags info.lpfn = 0; // callback function // execute the browsing dialog pidl = SHBrowseForFolder(&info); // pidl will be null if they cancel the browse dialog. // pidl will be not null when they select a folder if(pidl) { // try to convert the pidl to a display string // return is true if success if(SHGetPathFromIDList(pidl, szDir)) { // set one caption to the directory path Label1->Caption = szDir; } // set another caption based on the display name Label2->Caption = info.pszDisplayName; // use the shell malloc com object to free the pidl. // then call Relasee to signal that we don't need // the shell malloc object anymore pShellMalloc->Free(pidl); } pShellMalloc->Release(); } } Understanding the purpose of SHGetMalloc SHBrowseForFolder returns a PIDL object. The PIDL is allocated by the shell's task allocator. When you're done using the PIDL, it must be released by the task allocator. In order to properly free the PIDL object, you must obtain a reference to the shell's task allocator by calling the SHGetMalloc function. You can then use the task allocator to deallocate the PIDL. SHGetMalloc returns a pointer to an IMalloc COM object. The IMalloc COM interface is documented in the OLE Reference MS help file that comes with C Builder. If you're not up to speed with COM (like...who is), then think of the IMalloc COM object as just another C object that has methods that you can call. The method that we need for this FAQ is the Free method. Free will release the PIDL object. When you're finished using the task alloctor, call the Release method of the IMalloc object. The pseudo-code below depicts the relationship between the COM methods and regular C code that we are more familiar with. COM code C psuedo-equivalent LPMALLOC pShellMalloc; // think of pShellMalloc as an object that SHGetMalloc(&pShellMalloc); // handles new and delete for OS shell tasks LPITEMIDLIST pidl; Tpidl *pidl; pidl = SHBrowseForFolder(...); pidl = new Tpidl(); pShellMalloc->Free(pidl); delete pidl; pShellMalloc->Release(); The BROWSEINFO structure The BROWSEINFO structure allows you to control the appearance and behavior of the SHBrowseForFolder dialog. Each BROWSEINFO structure is described below. typedef struct { HWND hwndOwner; LPCITEMIDLIST pidlRoot; LPSTR pszDisplayName; LPCSTR lpszTitle; UINT ulFlags; BFFCALLBACK lpfn; LPARAM lParam; int iImage; } BROWSEINFO; hwndOwner: Specifies the handle of the owner window of the browsing dialog. If you supply an owner, the browse dialog will behave modally with respect to the owner window. The user will not be able to interact with your program while the browse dialog is displayed. This is usually the effect that you want. Also, when you specify an owner, the taskbar will not display a separate icon for the browsing dialog. If you set hwndOwner to NULL, then the browsing dialog behaves like a separate window that is not part of your program. Users will still be able to interact with your program and the browsing dialog will have its own taskbar icon. pidlRoot: Specifies the root PIDL, or directory, of the browsing dialog. The root PIDL acts like the base folder for the dialog. The user cannot backup past the root folder. For example, let's say that you want your users to select a folder on the C: drive. You could obtain a PIDL for the C:\ drive (how you obtain that is complicated enough to warrant its own FAQ), and then assign this PIDL to the pidlRoot member of BROWSEINFO. The browsing dialog would not allow the user to backup past the root directory of the C: drive. pszDisplayName: The browse dialog writes the title of the selected folder into the pszDisplayName member of BROWSEINFO. You should point this member to a buffer that can hold at least MAX_PATH characters. Note that the display name is not the same thing as the directory path to the folder. lpszTitle: This parameter allows you to specify text that the browse info dialog will display just above the directory treeview (see Figure 1). ulFlags: Controls the type of folders that the user can browse for. The possible values are: BIF_BROWSEFORCOMPUTER Browses only for computers (network neighborhood). BIF_BROWSEFORPRINTER Browses for network printers (somewhat useless). BIF_DONTGOBELOWDOMAIN Prevents display of network folders below domain level. BIF_RETURNFSANCESTORS Returns file system items (drives and directories). BIF_RETURNONLYFSDIRS Returns file system ancestors (so what are those??). BIF_STATUSTEXT Displays a label on the browse dialog. Be careful when trying to control SHBrowseFolder by altering the ulFlags structure member. You might not get the results that you expect. For example, if you specify the BIF_BROWSEFORPRINTER flag, you might expect that the user will be able to select a local printer that is connected directly to their PC. This turns out to be false. The BIF_BROWSEFORPRINTER only allows the user to browse for network printers. Also, it doesn't seem to prevent them form selecting a file directory (at least, not when I tried it). lpfn: Pointer to a callback routine. An example is shown below. lParam: Value that is used in the callback routine. iImage: The folder that is selected by SHBrowseForFolder will have an associated icon of some kind. When SHBrowseForFolder closes, iImage contains an integer value. This value is the selected folder's index into the system imagelist. If you don't know what the system imagelist is, see my FAQ on displaying the same icons that Windows displays. Using a SHBrowseForFolder callback routine Two of the BROWSEINFO members pertain to some mystical callback hocus pocus. So what is this callback jazz all about? The callback routine exists so you can customize the behavior of the SHBrowseForFolder dialog. For example, if you don't like (or don't understand, like my) why the ulFlags parameter doesn't seem to behave correctly, you can take control of the browse dialog yourself by using a callback. The callback allows you to enable and disable the browse dialog's OK button. You can also navigate the dialog to a specific folder or set the status text. Here is a code example that demonstrates how to utilize the browse dialog's callback function. This code sets the status text of the dialog, and it initialize the browse dialog to a specific directory. The code also tracks the current selection in the browse dialog and displays the folder path in a label. int __stdcall BrowseProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData ) { char szDir[MAX_PATH]; switch(uMsg) { case BFFM_INITIALIZED: SendMessage(hwnd, BFFM_SETSTATUSTEXT,0, (LPARAM)"Greetings"); // Set the initial directory. If WPARAM is TRUE, then LPARAM is a // string that contains the path. If WPARAM is FALSE, then LPARAM // should be a lovely PIDL SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)"C:\\Delphi4"); break; case BFFM_SELCHANGED: if(SHGetPathFromIDList((LPITEMIDLIST)lParam, szDir)) Form1->Label3->Caption = szDir; break; } return 0; } void __fastcall TForm1::Button1Click(TObject *Sender) { BROWSEINFO info; char szDir[MAX_PATH]; char szDisplayName[MAX_PATH]; LPITEMIDLIST pidl; LPMALLOC pShellMalloc; if(SHGetMalloc(&pShellMalloc) == NO_ERROR) { memset(&info, 0x00, sizeof(info)); info.hwndOwner = 0; info.pidlRoot = NULL; info.pszDisplayName = szDisplayName; info.lpszTitle = "Browse Title"; info.ulFlags = BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT; info.lpfn = BrowseProc; // callback function pidl = SHBrowseForFolder(&info); if(pidl) { if(SHGetPathFromIDList(pidl, szDir)) { Label1->Caption = szDir; } Label2->Caption = info.pszDisplayName; pShellMalloc->Free(pidl); pShellMalloc->Release(); } } }
lcsboy
版主


發表:87
回覆:622
積分:394
註冊:2002-06-18

發送簡訊給我
#10 引用回覆 回覆 發表時間:2002-10-20 01:04:57 IP:210.85.xxx.xxx 未訂閱
啊這...........是一個API也是寫在shlobj.h裡    重點是....單獨#include 是會有多重宣告的error!
lcsboy
版主


發表:87
回覆:622
積分:394
註冊:2002-06-18

發送簡訊給我
#11 引用回覆 回覆 發表時間:2002-10-20 03:10:57 IP:210.85.xxx.xxx 未訂閱
To Turboted:    玩了一下下範例!  原來..........為了call一個API SHBrowseForFolder(); 弄了那麼又臭又長...... 結果.........BCB已經內建了一個東東是相同功能:SelectDirectory    分享一下! #include  String S; S=""; SelectDirectory("Select Directory", "", S); 其實BCB6 沒有比較強....只是BCB5有支援的東西, 並不是像VC那樣子用的. 因為SDK寫的是用VC , 所以, BCB有自己的一套方式.... 等我研究好範例, 再跟各位報告一下, 怎麼丟掉難看的Win3.1的元件 還可以選用系統的..My computer, My document....etc
RaynorPao
版主


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

發送簡訊給我
#12 引用回覆 回覆 發表時間:2002-10-31 08:31:10 IP:203.73.xxx.xxx 未訂閱
引言: 啊這...........是一個API也是寫在shlobj.h裡 重點是....單獨#include 是會有多重宣告的error!
版主大大~~有人找到答案了耶
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
lcsboy
版主


發表:87
回覆:622
積分:394
註冊:2002-06-18

發送簡訊給我
#13 引用回覆 回覆 發表時間:2002-10-31 10:36:03 IP:211.23.xxx.xxx 未訂閱
Shlobj.h <-------------- 為什麼#include進來會error!    經過小弟偶前幾天的測試 把.cpp最前面的vcl.h拿掉, complie就過了
系統時間:2024-07-05 0:02:23
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!