Click here to Skip to main content
15,884,969 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to identify the drive type? Pin
Richard MacCutchan4-Sep-12 22:08
mveRichard MacCutchan4-Sep-12 22:08 
GeneralRe: how to identify the drive type? Pin
VCProgrammer4-Sep-12 22:15
VCProgrammer4-Sep-12 22:15 
GeneralRe: how to identify the drive type? Pin
Richard MacCutchan4-Sep-12 23:00
mveRichard MacCutchan4-Sep-12 23:00 
GeneralRe: how to identify the drive type? Pin
VCProgrammer5-Sep-12 2:54
VCProgrammer5-Sep-12 2:54 
GeneralRe: how to identify the drive type? Pin
Richard MacCutchan5-Sep-12 3:06
mveRichard MacCutchan5-Sep-12 3:06 
GeneralRe: how to identify the drive type? Pin
VCProgrammer5-Sep-12 21:36
VCProgrammer5-Sep-12 21:36 
GeneralRe: how to identify the drive type? Pin
Richard MacCutchan5-Sep-12 23:12
mveRichard MacCutchan5-Sep-12 23:12 
GeneralRe: how to identify the drive type? Pin
VCProgrammer12-Sep-12 23:16
VCProgrammer12-Sep-12 23:16 
using this to get hard disk num of selected drive

CString drive_is;//logical drive letter
	int ret_disk_num=-1;//disk numer of passed logical drive

	drive_is.Remove('\\');
	drive_is.Trim();

	CString szDrive=_T("\\\\.\\");
	szDrive+= drive_is;

		
	int rt;
	
	HANDLE h = CreateFile(szDrive, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,/*0*/FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,NULL);
	if(INVALID_HANDLE_VALUE != h)
	{
		VOLUME_DISK_EXTENTS vdExtents;
		ZeroMemory(&vdExtents, sizeof(vdExtents));

		DWORD d =32;
					
		DWORD dwRet;
		rt = DeviceIoControl(h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &vdExtents, d, &dwRet, NULL);
			
		CloseHandle(h);
		h=NULL;

		if(rt != 0)
		{
			//vdExtents.Extents[0].DiskNumber;

			for (DWORD n = 0; n < vdExtents.NumberOfDiskExtents; ++n)
			{
				PDISK_EXTENT pDiskExtent = &vdExtents.Extents[n];
				
				ret_disk_num =pDiskExtent->DiskNumber;
				
			}
		}
		else
		{
			DWORD d;
			d = GetLastError();

		}
			 	
		if(h!=NULL)
			CloseHandle(h);
	}
	else
	{
		

		return ret_disk_num;
	}

	return ret_disk_num;	 
}


after getting disk drive num chek the media type of drive using Win32_DiskDrive.
QuestionHelp with threads Pin
AndrewG12314-Sep-12 9:31
AndrewG12314-Sep-12 9:31 
AnswerRe: Help with threads Pin
pasztorpisti4-Sep-12 10:01
pasztorpisti4-Sep-12 10:01 
SuggestionRe: Help with threads Pin
David Crow4-Sep-12 10:09
David Crow4-Sep-12 10:09 
GeneralRe: Help with threads Pin
AndrewG12314-Sep-12 10:17
AndrewG12314-Sep-12 10:17 
SuggestionRe: Help with threads Pin
pasztorpisti4-Sep-12 12:09
pasztorpisti4-Sep-12 12:09 
QuestionRe: Help with threads Pin
AndrewG12314-Sep-12 13:37
AndrewG12314-Sep-12 13:37 
AnswerRe: Help with threads Pin
pasztorpisti4-Sep-12 14:18
pasztorpisti4-Sep-12 14:18 
GeneralRe: Help with threads Pin
Joe Woodbury4-Sep-12 17:16
professionalJoe Woodbury4-Sep-12 17:16 
GeneralRe: Help with threads Pin
pasztorpisti4-Sep-12 22:33
pasztorpisti4-Sep-12 22:33 
GeneralRe: Help with threads Pin
Albert Holguin5-Sep-12 12:23
professionalAlbert Holguin5-Sep-12 12:23 
GeneralRe: Help with threads Pin
Richard MacCutchan4-Sep-12 22:06
mveRichard MacCutchan4-Sep-12 22:06 
QuestionRe: Help with threads Pin
David Crow5-Sep-12 3:15
David Crow5-Sep-12 3:15 
AnswerRe: Help with threads Pin
pasztorpisti5-Sep-12 3:31
pasztorpisti5-Sep-12 3:31 
GeneralRe: Help with threads Pin
David Crow5-Sep-12 3:46
David Crow5-Sep-12 3:46 
GeneralRe: Help with threads Pin
pasztorpisti5-Sep-12 3:55
pasztorpisti5-Sep-12 3:55 
GeneralRe: Help with threads Pin
Albert Holguin5-Sep-12 12:26
professionalAlbert Holguin5-Sep-12 12:26 
AnswerRe: Help with threads Pin
Chuck O'Toole5-Sep-12 3:57
Chuck O'Toole5-Sep-12 3:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.