如何偵測隨身碟對插拔動作,並取得隨身碟的磁碟代號? |
答題得分者是:yckuo
|
haman
中階會員 發表:46 回覆:137 積分:56 註冊:2005-03-10 發送簡訊給我 |
|
yckuo
高階會員 發表:55 回覆:389 積分:238 註冊:2003-03-07 發送簡訊給我 |
取得磁碟機代號
<textarea class="cpp" rows="10" cols="60" name="code"> void __fastcall TForm1::search_driver(void) { LPTSTR lpBuffer ; DWORD dwDeviceCnt; dwDeviceCnt = GetLogicalDriveStrings( 0, lpBuffer ); if(dwDeviceCnt) { char *buf = new char [dwDeviceCnt]; GetLogicalDriveStrings(dwDeviceCnt, buf ); std::vector
------
yckuo |
axsoft
版主 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
Win32 Application Support for Plug and Play
http://msdn2.microsoft.com/en-US/library/ms810038.aspx 關於USB裝置插入的問題 http://topic.csdn.net/t/20050305/21/3827513.html |
axsoft
版主 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
Detecting Media Insertion or Removalhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/detecting_media_insertion_or_removal.aspWindows sends all top-level windows a set of default WM_DEVICECHANGE messages when new devices or media (such as a CD or DVD) are added and become available, and when existing devices or media are removed. You do not need to register to receive these default messages. See the Remarks section in RegisterDeviceNotification for details on which messages are sent by default. The messages in the code example below are among the default messages. Each WM_DEVICECHANGE message has an associated event that describes the change, and a structure that provides detailed information about the change. The structure consists of an event-independent header, DEV_BROADCAST_HDR, followed by event-dependent members. The event-dependent members describe the device to which the event applies. To use this structure, applications must first determine the event type and the device type. Then, they can use the correct structure to take appropriate action. When the user inserts a new CD or DVD into a drive, applications receive a WM_DEVICECHANGE message with a DBT_DEVICEARRIVAL event. The application must check the event to ensure that the type of device arriving is a volume (the dbch_devicetype member is DBT_DEVTYP_VOLUME) and that the change affects the media (the dbcv_flags member is DBTF_MEDIA). When the user removes a CD or DVD from a drive, applications receive a WM_DEVICECHANGE message with a DBT_DEVICEREMOVECOMPLETE event. Again, the application must check the event to ensure that the device being removed is a volume and that the change affects the media. The following code demonstrates how to check for insertion or removal of a CD or DVD. <textarea class="cpp" rows="10" cols="60" name="code"> #include |
pcboy
版主 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
參考看看
[所有][發表] 偵測USB儲存裝置的插拔和磁碟代號(含SourceCode) http://delphi.ktop.com.tw/board.php?cid=31&fid=79&tid=91493
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |