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

硬碟型態

尚未結案
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-02-11 18:28:39 IP:61.222.xxx.xxx 未訂閱
請問如何找硬碟型態 ~我還在學習狀態希望多多向您學習~ 發表人 - taishyang 於 2004/02/11 19:07:17
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-02-11 18:33:51 IP:61.221.xxx.xxx 未訂閱
重reg找有關bois把 比較快
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-02-12 15:07:13 IP:61.222.xxx.xxx 未訂閱
在那找不懂 ~我還在學習狀態希望多多向您學習~
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-02-12 16:00:04 IP:61.221.xxx.xxx 未訂閱
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-02-12 16:06:00 IP:61.222.xxx.xxx 未訂閱
可能是我講的不清楚不好意思 我是要用c 來找硬碟型態 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-02-12 16:09:18 IP:61.218.xxx.xxx 未訂閱
conundrum兄是要您用TRegistry 來讀Registry的內容,但如果Registry中沒有那你要的資訊那...就準被乾瞪眼吧..      如果您要寫Hardware informan的東西,建議您從Windows DDK 的SetupDiXXXXX API著手吧!    參考網頁 http://www.csdn.net/develop/author/netauthor/bhw98/    Delphi範例: http://delphi.ktop.com.tw/loadfile.php?TOPICID=14008954&CC=313306
BCB中需要作下面準備工作
1.在C++ Builder 6 中C:\Program Files\Borland\CBuilder6\Lib\Psdk\SetupAPI.LIB 加入您的Project File
2.#include  
  #include 
  #include 
 
在你的Project Unit1中...
3.這有位Ktop會員寫的Source Code( Sorry...忘了是那位了)
//.cpp
#include 
#pragma hdrstop
#include  // DDK SetupAPI API include File
#include   // Device Guid include File
#include  // Windows IO Control Define include File
#pragma package(smart_init)
#pragma resource "*.dfm"
#define INTERFACE_DETAIL_SIZE    (1024)
#define MAX_DEVICE                16
TForm1 *Form1;    __fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}    int __fastcall TForm1::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
{
        HDEVINFO hDevInfoSet;
        SP_DEVICE_INTERFACE_DATA ifdata;
        PSP_DEVICE_INTERFACE_DETAIL_DATA pDetail;
        int nCount;
        BOOL bResult;            hDevInfoSet = ::SetupDiGetClassDevs(lpGuid,
                        NULL,
                        NULL,
                        DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);            if(hDevInfoSet == INVALID_HANDLE_VALUE)
        {
                return 0;
        }            pDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)::GlobalAlloc(LMEM_ZEROINIT, INTERFACE_DETAIL_SIZE);            pDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);            nCount = 0;
        bResult = TRUE;            while (bResult)
        {
                ifdata.cbSize=sizeof(ifdata);                    bResult = ::SetupDiEnumDeviceInterfaces(
                                hDevInfoSet,
                                NULL,
                                lpGuid,
                                (ULONG)nCount,
                                &ifdata);                    if(bResult)
                {
                        bResult = SetupDiGetInterfaceDeviceDetail(
                                        hDevInfoSet,
                                        &ifdata,
                                        pDetail,
                                        INTERFACE_DETAIL_SIZE,
                                        NULL,
                                        NULL);                            if(bResult)
                        {
                                ::strcpy(pszDevicePath[nCount], pDetail->DevicePath);
                Memo1->Lines->Add(pDetail->DevicePath);
                                nCount++;
                        }
                }
        }            ::GlobalFree(pDetail);            ::SetupDiDestroyDeviceInfoList(hDevInfoSet);            return nCount;
}    void __fastcall TForm1::Button1Click(TObject *Sender)
{            HANDLE hDevice;            String strInfo;
        int nDevice;
        int i,j;
        char* szDevicePath[MAX_DEVICE];
        LPGUID lpGuid[] = {
                (LPGUID)&DiskClassGuid,
                (LPGUID)&CdRomClassGuid,
                (LPGUID)&StoragePortClassGuid,
        (LPGUID)&MediumChangerClassGuid
        };            for(i=0 ; i < MAX_DEVICE ; i++) szDevicePath[i]=new char[256];            for(i=0; i < sizeof(lpGuid) / sizeof(LPGUID) ; i++)
        {
                nDevice=GetDevicePath(lpGuid[i], szDevicePath);
        }            for(i=0 ; i < MAX_DEVICE ; i++) delete []szDevicePath[i];    }        Unit1.h 
   //---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include 
#include 
#include 
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
 {
  __published: // IDE-managed Components        
               TMemo *Memo1;        
               TButton *Button1;        
               void __fastcall Button1Click(TObject *Sender);
 private: // User      declarationspublic:  // User declarations        
               __fastcall TForm1(TComponent* Owner);        
           int __fastcall GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
 };
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif    
/*生活是一種藝術,用心生活才能享受生活*/
發表人 - axsoft 於 2004/02/12 16:27:41
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-02-12 16:52:55 IP:61.221.xxx.xxx 未訂閱
http://delphi.ktop.com.tw/topic.php?topic_id=27077 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=30705 axsoft 兄不愧為 BCB高手 kraen4468 兄 搜索的技巧問題的深度 請再用力一下 不然字會越來越少 興趣越來越低 加油 希望下次是你來解答 發表人 - conundrum 於 2004/02/12 16:57:33
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-02-12 17:22:27 IP:61.222.xxx.xxx 未訂閱
The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.     UINT GetDriveType(        LPCTSTR lpRootPathName         // address of root path 
   );        
     Parameters    lpRootPathName    Points to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory.          Return Values    The return value specifies the type of drive. It can be one of the following values:     Value        Meaning
0        The drive type cannot be determined.
1        The root directory does not exist.
DRIVE_REMOVABLE        The drive can be removed from the drive.
DRIVE_FIXED        The disk cannot be removed from the drive.
DRIVE_REMOTE        The drive is a remote (network) drive.
DRIVE_CDROM        The drive is a CD-ROM drive.
DRIVE_RAMDISK        The drive is a RAM disk.
這是我後來找到的 謝謝大大前面的保貴資料 ~我還在學習狀態希望多多向您學習~
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-02-12 18:03:21 IP:61.222.xxx.xxx 未訂閱
我試了GetDriveType的API可是都寫不出來 可以請大大教我這個API怎麼用嗎 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#10 引用回覆 回覆 發表時間:2004-02-12 23:19:42 IP:211.76.xxx.xxx 未訂閱
引言: 我試了GetDriveType的API可是都寫不出來 可以請大大教我這個API怎麼用嗎 ~我還在學習狀態希望多多向您學習~
Kraen4468您好:    void __fastcall TForm1::Button1Click(TObject *Sender)
{
    AnsiString Drive = "C:\\";
    int type = GetDriveType( Drive.c_str() );        AnsiString DriveType;        if ( type == 0 ){
        DriveType = "The drive type cannot be determined.";
    }
    else if ( type == 1 ){
        DriveType = "The root directory does not exist.";
    }
    else if ( type == 2 ){
        DriveType = "The drive can be removed from the drive";
    }
    else if ( type == 3 ){
        DriveType = "The disk cannot be removed from the drive.";
    }
    else if ( type == 4 ){
        DriveType = "The drive is a remote (network) drive.";
    }
    else if ( type == 5 ){
        DriveType = "The drive is a CD-ROM drive.";
    }
    else if ( type == 6 ){
        DriveType = "The drive is a RAM disk.";
    }        MessageDlg( DriveType, mtInformation, TMsgDlgButtons() << mbOK, 0 );
}
/*生活是一種藝術,用心生活才能享受生活*/
kraen4468
初階會員


發表:66
回覆:112
積分:35
註冊:2003-12-04

發送簡訊給我
#11 引用回覆 回覆 發表時間:2004-02-13 10:11:13 IP:61.222.xxx.xxx 未訂閱
Drive.c_str() 
可以問一個小問題嗎後面加.c_str()是什麼意思呢 ~我還在學習狀態希望多多向您學習~
axsoft
版主


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

發送簡訊給我
#12 引用回覆 回覆 發表時間:2004-02-13 19:06:28 IP:61.218.xxx.xxx 未訂閱
引言:
Drive.c_str() 
可以問一個小問題嗎後面加.c_str()是什麼意思呢 ~我還在學習狀態希望多多向您學習~
kraen4468 c_str()是將AnsiString 轉為轉為字元陣列格式 建議您多看看C Builder 基礎的書籍
AnsiString 字串處理    在C語言裡,字串處理多用字元陣列來做,使用上不很親切。     在C  Builder中,實作了AnsiString 類別來處理字串,提供更好的選擇。(AnsiString 可以 String表示)      String str;
  str=String("This is a line of text");  // 建構子
  str=String(0);                         // 建構子
  str=String(34.234);                    // 建構子
  
  String stra=String("String a");
  String strb=String("String b");
  String strc;
  strc=stra strb;                       // 字串的串接
  if(stra.AnsiCompare(strb))            // 字串的比較
   {...}
 int index;
  index=strc.AnsiPos("ring");           // 子字串的尋找     MessageBox(strc.c_str(),stra.c_str(),MB_OK); // 轉為字元陣列格式
 index=strc.Length();                 // 字串長度
 
 str=strc.SubString(3,4);             // 擷取子字串
  str=strc.UpperCase();                // 全改為大寫字母
 str=strc.LowerCase();                // 全改為小寫字母
  int x;
  str="20";
  x=str.ToInt();                       // 轉為整數
 float r;
  str="20.334";
  r=str.ToDouble();                   // 轉為浮點數    
/*生活是一種藝術,用心生活才能享受生活*/
發表人 - axsoft 於 2004/02/13 19:07:57
系統時間:2024-05-02 3:45:39
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!