We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,151 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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

2
Contributors
1
Reply
1 Week
Discussion Span
2 Years Ago
Last Updated
2
Views
newbgal
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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);
wisaacs
Light Poster
46 posts since Jun 2010
Reputation Points: 8
Solved Threads: 5
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0570 seconds using 2.67MB