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

請問我的最愛的實作,不是匯出,匯入那種

尚未結案
qubeley2004
一般會員


發表:52
回覆:71
積分:24
註冊:2004-07-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-24 20:20:31 IP:219.91.xxx.xxx 未訂閱
關於我的最愛如同IE那樣...不是匯出匯入那種..文章我已經看過了,不過還是不了解怎麼弄出我的最愛..像是IE這樣,按下去之後會跑出我已經儲存的網路竭盡..不是要匯出匯入那種...如同以下 點選一個之後就會轉到其點選的網頁去 之前參閱的文章是會出現視窗問你要不要匯出我的最愛或是匯入..而我要的不是那個..而是如同ie那樣的捷徑 發表人 - qubeley2004 於 2004/07/24 20:23:10
andychang1690
資深會員


發表:20
回覆:694
積分:442
註冊:2003-03-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-26 09:57:51 IP:219.132.xxx.xxx 未訂閱
來自對岸的一編文章    http://zealot.yculblog.com/post-68455.html    但是是使用Delphi寫的    主題:怎樣將IE收藏夾的內容轉錄到TTreeView控制中
Night @ 07-02 16:31    我們如何取得IE收藏夾的內容,並將其用一個TTreeView表示出來呢?在下面我將自己實現的例子貼在這兒,以讓同仁參考一下:     要求:在Form中放兩個TTreeView (tv_FileName, tv_URLName)控制,一個功能表並加一個功能表項mnup_Get。 
您將下面的主要代碼貼到這個功能表項的OnClick事件中就行了。至如結果怎?樣,嘻嘻,你試過就知道的喔.....     如下是主要的代碼     const 
 IMAGENUM_BOOKCLOSE = 0; //關閉的類型標誌 
 IMAGENUM_BOOKOPEN  = 1; //網路位址標誌 
 IMAGENUM_URLPAGE   = 2; //打開的類型標誌     type 
 Tdlg_URLTree = class(TForm) 
   tv_FileName: TTreeView;  //存放目錄或檔案名的控制項 
   tv_URLName: TTreeView;   //存放URL位元址的控制 
   mnup_Get: TMenuItem;     //功能表項     ...     var 
 dlg_URLTree: Tdlg_URLTree;     implementation 
uses IniFiles;     procedure Tdlg_URLTree.mnup_GetClick(Sender: TObject); 
 //取得網址的函數 
 procedure FF_GetDirFileName(strPath: String;  //路徑 
                             tvFile, //存放目錄或檔案名的TTreeView控制項 
                             tvURL: TTreeView);  //存放URL名的TTreeView控制項 
 var 
   intRet: Integer; 
   DirInfo: TSearchRec; 
   strIniFile: TIniFile; 
   buffer: String; 
   tnNew: TTreeNode; 
 begin 
   intRet := FindFirst(strPath   '\*.*', FaAnyfile, DirInfo);        while intRet = 0 do 
   begin 
      if (DirInfo.Name <> '.') and   //濾掉 .目錄 
         (DirInfo.Name <> '..') and  //濾掉 ..目錄 
         (Pos('.lnk', DirInfo.Name) = 0) and  //濾掉 *.lnk文件 
         (Pos('.ini', DirInfo.Name) = 0) then //濾掉 *.ini文件 
      begin 
        if (DirInfo.Attr and FaDirectory = FaDirectory) then 
        begin 
          tnNew := tvFile.Items.AddChild(tvFile.Selected, DirInfo.Name); 
          tnNew.Selected := True; 
          tnNew.ImageIndex := IMAGENUM_BOOKCLOSE;   //設定分類目錄節點的圖示 
          tnNew.SelectedIndex := IMAGENUM_BOOKOPEN; 
          (tvURL.Items.AddChild(tvURL.Selected, DirInfo.Name)).Selected := True; 
          FF_GetDirFileName(strPath   '\'   DirInfo.Name, tvFile, tvURL); 
        end else 
            begin 
              buffer := DirInfo.Name; 
              Delete(buffer, Pos('.url', buffer), 4); //濾掉檔案名中的 .url 
              //添加名稱到 tvFile中                   tnNew := tvFile.Items.AddChild(tvFile.Selected, buffer); 
              tnNew.ImageIndex := IMAGENUM_URLPAGE;  //設定Web頁節點的圖示 
              tnNew.SelectedIndex := tnNew.ImageIndex; 
              //得到URL,並加入到tvURL樹中 
              strIniFile := TIniFile.Create(strPath   '\'   DirInfo.Name); 
              buffer := strIniFile.ReadString('InternetShortcut','URL',''); 
              strIniFile.Destroy; 
              tvURL.Items.AddChild(tvURL.Selected, buffer); 
            end; 
      end; 
      intRet := FindNext(DirInfo); 
   end;        //重置檔案名樹tvFile的焦點 
   if tvFile.Selected <> nil then 
   if tvFile.Selected.Parent <> nil then 
      (tvFile.Selected.Parent).Selected := True 
   else (tvFile.Selected).Selected := False;        //重置Web地址樹tvURL的焦點 
   if tvURL.Selected <> nil then 
   if tvURL.Selected.Parent <> nil then 
      (tvURL.Selected.Parent).Selected := True 
   else (tvURL.Selected).Selected := False; 
    
   SysUtils.FindClose(DirInfo); 
 end;     var 
 strURLFileName: TFileName; 
 pWinDir:pchar;  //windows目錄 
begin 
 GetMem(pWinDir, 256); 
 GetWindowsDirectory(pWinDir,128); 
 strURLFileName := pWinDir   '\Favorites'; 
 FreeMem(pWinDir); 
 //取得收藏夾的內容 
 FF_GetDirFileName(strURLFileName, tv_FileName, tv_URLName); 
end;     請參考!    
Andy Chang
------
Andy Chang
andychang1690
資深會員


發表:20
回覆:694
積分:442
註冊:2003-03-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-07-27 17:55:33 IP:219.132.xxx.xxx 未訂閱
給你一個將IE我的最愛所有內容置入Memo1的方法
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  PItemIDList pidl;
  char FavPath[255];
  // CSIDL_FAVORITES 我的最愛目錄
  SHGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, &pidl);
  SHGetPathFromIDList(pidl, FavPath);
  Label1->Caption=FavPath;
  Memo1->Clear();
  FindFilesInDirectory (Label1->Caption "\\","*.url");    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FindFilesInDirectory (String &directory,String fileext)
{
  AnsiString SFileName;
  WIN32_FIND_DATA filedata ;  // Structure for file data
  HANDLE filehandle ;         // Handle for searching
  // Pass 1 - Search for the files within the directory.
  filehandle = FindFirstFile ((directory   fileext).c_str (), &filedata) ;
  if (filehandle != INVALID_HANDLE_VALUE)
  {
    do  {
      SFileName=filedata.cFileName;
      if ( SFileName!= "." && SFileName != "..") {
        Memo1->Lines->Add(directory   SFileName); // 你也可以將副檔名.url去掉處理
      }        } while (FindNextFile (filehandle, &filedata)) ;
    FindClose (filehandle) ;
  }
  // 找子目錄
  String dir = directory   fileext ;
  filehandle = FindFirstFile ((directory   fileext).c_str (), &filedata) ;
  if (filehandle != INVALID_HANDLE_VALUE)
  {
    do  {
      if ((filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0
           && String (filedata.cFileName) != "."
           && String (filedata.cFileName) != "..") {
        FindFilesInDirectory (directory   filedata.cFileName   "\\","*.url") ;
      }
    } while (FindNextFile (filehandle, &filedata)) ;
    FindClose (filehandle) ;
  }      Application->ProcessMessages () ;      return ;
}
請參考
Andy Chang
------
Andy Chang
qubeley2004
一般會員


發表:52
回覆:71
積分:24
註冊:2004-07-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-07-27 22:21:34 IP:211.76.xxx.xxx 未訂閱
對不起..請問兩個蠢問題..    1.SHGetSpecialFolderLocation是在哪個dll中? (是#include 嗎...可是會跑出Shlobh.h的程式碼出現一堆重複宣告的錯誤??) 2. void __fastcall TForm1::FindFilesInDirectory (String &directory,String fileext) 請問這個是什麼元件呢?? 發表人 - qubeley2004 於 2004/07/27 22:36:17
andychang1690
資深會員


發表:20
回覆:694
積分:442
註冊:2003-03-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-07-28 08:07:33 IP:219.130.xxx.xxx 未訂閱
對不起.cpp
#define NO_WIN32_LEAN_AND_MEAN // 請加在vcl.h前    #include 
#pragma hdrstop    #include "Unit1.h"
#include "ShlObj.h"
紅字部分引述加入即可
void __fastcall TForm1::FindFilesInDirectory (String &directory,String fileext)
一看也知道是副程式請在.hpp檔
private:        // User declarations
  void __fastcall FindFilesInDirectory (String &directory,String fileext);
加入宣告    請參考
Andy Chang
------
Andy Chang
qubeley2004
一般會員


發表:52
回覆:71
積分:24
註冊:2004-07-13

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-07-28 19:20:47 IP:211.76.xxx.xxx 未訂閱
嗯,謝謝您的幫忙,我想我知道下一部要做些什麼~
系統時間:2024-04-29 5:19:24
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!