如何识别插入的光盘是否为CD_R [英] How to Identify inserted disc is CD_R or not

查看:64
本文介绍了如何识别插入的光盘是否为CD_R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查找插入的光盘是CD_R还是CD_ROM或CD_RW.为此,我使用了imapiv1.代码如下.

I want to find whether the inserted disc is CD_R or CD_ROM or CD_RW. For that i used imapiv1. The code is as follows.

IDiscMaster* pDiscMaster = NULL;
CoInitialize( NULL );
HRESULT hResult = CoCreateInstance( CLSID_MSDiscMasterObj, NULL,LSCTX_LOCAL_SERVER, 								IID_IDiscMaster, (void**)&pDiscMaster);
hResult = pDiscMaster->Open();
IEnumDiscRecorders* pEnumRecord;
hResult = pDiscMaster->EnumDiscRecorders( &pEnumRecord );
while(1)
	{
	IDiscRecorder* pDiscRecorder = NULL;
	ULONG lfetch;
	hResult = pEnumRecord->Next( 1, &pDiscRecorder, &lfetch);
	if( !pDiscRecorder) break;
	long MediaType, MediaFlags;
	hResult = pDiscRecorder->QueryMediaType(&MediaType, &MediaFlags);
	if(SUCCEEDED(hResult))
	{
	if(MediaType == MEDIA_CD_EXTRA)
		AfxMessageBox(_T("MediaType : MEDIA_CD_EXTRA\n") );
	else if(MediaType == MEDIA_CD_I)
		AfxMessageBox(_T(" MediaType : MEDIA_CD_I\n")    );
	else if(MediaType == MEDIA_CD_OTHER)
		AfxMessageBox(_T(" MediaType : MEDIA_CD_OTHER\n"));
	else if(MediaType == MEDIA_CD_ROM_XA)
		AfxMessageBox(_T(" MediaType : MEDIA_CD_ROM_XA\n"));
	else if(MediaType == MEDIA_CDDA_CDROM)
		AfxMessageBox(_T(" MediaType : MEDIA_CDDA_CDROM\n"));
	else if(MediaType == MEDIA_SPECIAL)
		AfxMessageBox(_T(" MediaType : MEDIA_SPECIAL\n") );
	if(MediaFlags & MEDIA_BLANK)
		AfxMessageBox(_T("MEDIA_BLANK, "));
	if(MediaFlags & MEDIA_RW)
		AfxMessageBox(_T("MEDIA_RW, "));
	if(MediaFlags & MEDIA_WRITABLE)
		AfxMessageBox(_T("MEDIA_WRITABLE, "));
	}	
}
		
pDiscMaster->Close();



但是下一步"函数返回s_false. pDiscRecorder的值为NULL.我不知道它怎么会失败..任何人都可以帮助我解决问题..
等待答复...



but "Next" function returns s_false. The value of pDiscRecorder is NULL. I don''t knw how it fails..Can anyone help me to solve the issue..
Waiting for the reply...

推荐答案

您可以尝试使用WMI:
http://msdn.microsoft.com/en-us/library/aa394346(VS .85).aspx [ ^ ]

本文将帮助您开始使用WMI:
Windows管理规范(WMI)实施 [
You could try to use WMI:
http://msdn.microsoft.com/en-us/library/aa394346(VS.85).aspx[^]

This article will get you started with WMI:
Windows Management Instrumentation (WMI) Implementation[^]

Best regards
Espen Harlinn


这篇关于如何识别插入的光盘是否为CD_R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆