Click here to Skip to main content
15,896,727 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMessge "the device is not ready" occur. Pin
Le@rner20-Aug-09 20:41
Le@rner20-Aug-09 20:41 
AnswerRe: Messge "the device is not ready" occur. Pin
_AnsHUMAN_ 20-Aug-09 21:51
_AnsHUMAN_ 20-Aug-09 21:51 
GeneralRe: Messge "the device is not ready" occur. Pin
Le@rner20-Aug-09 21:57
Le@rner20-Aug-09 21:57 
QuestionConverting CString to int Pin
Le@rner20-Aug-09 18:47
Le@rner20-Aug-09 18:47 
AnswerRe: Converting CString to int Pin
Adam Roderick J20-Aug-09 19:11
Adam Roderick J20-Aug-09 19:11 
GeneralRe: Converting CString to int Pin
Le@rner20-Aug-09 19:37
Le@rner20-Aug-09 19:37 
QuestionRetreive Hard Disk Interface Type Pin
Abinash Mohanty20-Aug-09 18:39
Abinash Mohanty20-Aug-09 18:39 
AnswerRe: Retreive Hard Disk Interface Type Pin
Randor 20-Aug-09 22:32
professional Randor 20-Aug-09 22:32 
Abinash Mohanty wrote:
Can anybody tell me how to retreive hard disk interface type without using WMI classes in MFC


Hi Abinash,

The MFC classes[^] are a very small subset of the Microsoft Windows API. The answer to your question is that MFC does not have any methods of determining a drive volume bus type.

But you can use the IOCTL_STORAGE_QUERY_PROPERTY[^] control code to obtain the STORAGE_BUS_TYPE[^]. Here is an example:

#include <winioctl.h>
#define IOCTL_STORAGE_QUERY_PROPERTY   CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)

STORAGE_BUS_TYPE GetDriveBusType(DWORD dwDrive)
{
	STORAGE_BUS_TYPE sbt = BusTypeUnknown;
	HANDLE hDrive;
	TCHAR szDrive[MAX_PATH];
	_stprintf(szDrive,_T("\\\\.\\PhysicalDrive%d"), dwDrive);
	hDrive = CreateFile(szDrive,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,NULL, OPEN_EXISTING, 0, NULL);
	if(INVALID_HANDLE_VALUE != hDrive)
	{
		DWORD dwSizeBytes;
		STORAGE_PROPERTY_QUERY q;
		ZeroMemory(&q,sizeof(STORAGE_PROPERTY_QUERY));
		PBYTE pBuf = (PBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(STORAGE_DESCRIPTOR_HEADER));
		if(NULL != pBuf)
		{
			if(TRUE == DeviceIoControl(hDrive,IOCTL_STORAGE_QUERY_PROPERTY,&q,sizeof(STORAGE_PROPERTY_QUERY),pBuf,sizeof(STORAGE_DESCRIPTOR_HEADER),&dwSizeBytes, NULL))
			{
				STORAGE_DESCRIPTOR_HEADER *pHeader = (STORAGE_DESCRIPTOR_HEADER *)pBuf;
				dwSizeBytes = pHeader->Size;
				pBuf = (PBYTE)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,pBuf,dwSizeBytes);
				if(NULL != pBuf)
				{
					if(TRUE == DeviceIoControl(hDrive,IOCTL_STORAGE_QUERY_PROPERTY,&q,sizeof(STORAGE_PROPERTY_QUERY),pBuf,dwSizeBytes,&dwSizeBytes, NULL))
					{
						STORAGE_DEVICE_DESCRIPTOR * pDesc = (STORAGE_DEVICE_DESCRIPTOR *)pBuf;
						sbt = pDesc->BusType;
					}
				}
			}
			HeapFree(GetProcessHeap(), 0, (LPVOID)pBuf);
		}
	}
	return sbt;
}


Best Wishes,
-David Delaune
QuestionADO Connection String. Pin
forexsurfr20-Aug-09 17:11
forexsurfr20-Aug-09 17:11 
AnswerRe: ADO Connection String. Pin
Rane20-Aug-09 18:12
Rane20-Aug-09 18:12 
AnswerRe: ADO Connection String. Pin
forexsurfr20-Aug-09 18:39
forexsurfr20-Aug-09 18:39 
GeneralRe: ADO Connection String. Pin
Rane21-Aug-09 0:55
Rane21-Aug-09 0:55 
QuestionHow can i do a unique reference to a function name that appear in two classes ? Pin
SNArruda20-Aug-09 13:40
SNArruda20-Aug-09 13:40 
AnswerRe: How can i do a unique reference to a function name that appear in two classes ? Pin
Chuck O'Toole20-Aug-09 15:13
Chuck O'Toole20-Aug-09 15:13 
GeneralRe: How can i do a unique reference to a function name that appear in two classes ? Pin
SNArruda20-Aug-09 16:49
SNArruda20-Aug-09 16:49 
GeneralRe: How can i do a unique reference to a function name that appear in two classes ? Pin
KarstenK20-Aug-09 21:33
mveKarstenK20-Aug-09 21:33 
GeneralRe: How can i do a unique reference to a function name that appear in two classes ? Pin
Stuart Dootson20-Aug-09 23:41
professionalStuart Dootson20-Aug-09 23:41 
QuestionSandCastle Help Builder with C++ Dynamic DLL (MFC) Pin
Member 437978320-Aug-09 11:22
Member 437978320-Aug-09 11:22 
AnswerRe: SandCastle Help Builder with C++ Dynamic DLL (MFC) Pin
Joe Woodbury20-Aug-09 17:43
professionalJoe Woodbury20-Aug-09 17:43 
GeneralRe: SandCastle Help Builder with C++ Dynamic DLL (MFC) Pin
Member 437978321-Aug-09 0:50
Member 437978321-Aug-09 0:50 
QuestionDefault type Pin
thelonesquirrely20-Aug-09 7:59
thelonesquirrely20-Aug-09 7:59 
AnswerRe: Default type Pin
Graham Shanks20-Aug-09 8:11
Graham Shanks20-Aug-09 8:11 
AnswerRe: Default type Pin
Maximilien20-Aug-09 8:19
Maximilien20-Aug-09 8:19 
GeneralRe: Default type Pin
thelonesquirrely20-Aug-09 8:22
thelonesquirrely20-Aug-09 8:22 
GeneralRe: Default type Pin
Maximilien20-Aug-09 9:08
Maximilien20-Aug-09 9:08 

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.