WinApi学习笔记-获取光驱中的信息

#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <cstring>

#define BUFSIZE 1024

int main(void)
{
	CHAR buf[BUFSIZE];
	PCHAR SzDrive; //CHAR的指针;
	CHAR myMessage[BUFSIZE];
	GetLogicalDriveStrings(BUFSIZE-1,buf);
	SzDrive = (PCHAR)buf;
	DWORD dwLastErr;
	DWORD dwFileSystemFlags;
	while(GetDriveType(SzDrive) != DRIVE_CDROM)
	{
		SzDrive += (lstrlen(SzDrive)+1);
	}	
	if(!GetVolumeInformation(
		SzDrive,NULL,0,NULL,NULL,&dwFileSystemFlags,buf,BUFSIZE
		))
	{
		dwLastErr = GetLastError();
		if(dwLastErr == 21)
		{
			MessageBox(NULL,"请放入光盘","提示",MB_OK);
			return 0;
		}
	}
	MessageBox(NULL,buf,"提示文件系统类别",MB_OK);
	return 0;
}
posted @ 2009-09-20 03:11  liulun  阅读(495)  评论(0编辑  收藏  举报