1.11M Members

Please help .....how can i get the drive information

 
0
 

Hi ..

this is my first post here...

i have been trying to solve this problem for two days ..but no luck..

here is my problemm...

I am using win32..

I can able to get notified on new device insertion and removal using DBT_DEVTYP_DEVICEINTERFACE

if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam )
{
PDEV_BROADCAST_HDR pHdr = ( PDEV_BROADCAST_HDR )lParam;

PDEV_BROADCAST_DEVICEINTERFACE pDevInf;

PDEV_BROADCAST_VOLUME pDevVolume = reinterpret_cast<PDEV_BROADCAST_VOLUME>(lParam);

switch( pHdr->dbch_devicetype )
{
case DBT_DEVTYP_DEVICEINTERFACE:
pDevInf = ( PDEV_BROADCAST_DEVICEINTERFACE )pHdr;
updateDevice( pDevInf, wParam);
break;
}
}

anybody please tell me how can i get the drive information ( G:/ ) for the above notication

any help would be greatly appreciated

 
0
 

This gets some basic device information.

//handle to the drive to be examined
	HANDLE hDevice	= CreateFile(TEXT("\\\\.\\G:"),	//Drive to open
		GENERIC_READ|GENERIC_WRITE,//Access to the drive
		FILE_SHARE_READ|FILE_SHARE_WRITE,//Share mode
		NULL,//Security
		OPEN_EXISTING,0,// no file attributes
		NULL);
	if (hDevice == INVALID_HANDLE_VALUE)//Cannot open the drive
		return 0;

	CDROM_TOC val; // table of contents for a generic CDROM
	DWORD nBytesReturned;

	BOOL bResult= DeviceIoControl(
		hDevice, 
		IOCTL_CDROM_READ_TOC,//operation to perform
		&val, sizeof(val),//no input buffer
		&val, sizeof(val),//output buffer
		&nBytesReturned,//#bytes returned
		(LPOVERLAPPED) NULL);//synchronous I/O		

	CloseHandle(hDevice);
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: