![](/img/trans.png)
[英]detect cd/dvd in cd drive and play on window media player
[英]How to detect media type in a CD/DVD drive without IMAPI in a C# application?
通過使用C#中的IMAPI方法,我可以輕松獲得插入的可寫介質的介質類型。 不幸的是,當我有只讀介質時,這些方法不起作用。 我想學習一種方法來確定驅動器中插入了哪種類型的介質。 也許我可以通過讀取光盤的總扇區大小來解決這個問題。
有人可以幫忙嗎?
您可以通過SHChangeNotifyRegister函數使用p / invoke嗎:
[DllImport("shell32.dll", SetLastError=true, EntryPoint="#2", CharSet=CharSet.Auto)]
static extern UInt32 SHChangeNotifyRegister(
IntPtr hWnd,
SHCNF fSources,
SHCNE fEvents,
uint wMsg,
int cEntries,
ref SHChangeNotifyEntry pFsne);
您可以偵聽SHCNE_MEDIAINSERTED事件,但是就檢測到它是哪種類型的媒體而言,我不確定,但是您可以調用另一個外部函數來獲取該信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.