Click here to Skip to main content
15,908,175 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ini file Pin
Adam Roderick J10-Aug-09 19:54
Adam Roderick J10-Aug-09 19:54 
Question#define problem Pin
kk.tvm10-Aug-09 19:02
kk.tvm10-Aug-09 19:02 
AnswerRe: #define problem Pin
Code-o-mat10-Aug-09 20:33
Code-o-mat10-Aug-09 20:33 
GeneralRe: #define problem Pin
kk.tvm10-Aug-09 22:24
kk.tvm10-Aug-09 22:24 
AnswerRe: #define problem Pin
Adam Roderick J10-Aug-09 20:36
Adam Roderick J10-Aug-09 20:36 
GeneralRe: #define problem Pin
kk.tvm10-Aug-09 22:26
kk.tvm10-Aug-09 22:26 
AnswerRe: #define problem Pin
Stuart Dootson10-Aug-09 21:29
professionalStuart Dootson10-Aug-09 21:29 
GeneralRe: #define problem Pin
kk.tvm10-Aug-09 22:26
kk.tvm10-Aug-09 22:26 
AnswerRe: #define problem Pin
David Crow11-Aug-09 3:18
David Crow11-Aug-09 3:18 
QuestionLNK errors while using an "extern "C"" function Pin
MozhdehQeraati10-Aug-09 18:43
MozhdehQeraati10-Aug-09 18:43 
AnswerRe: LNK errors while using an "extern "C"" function Pin
«_Superman_»10-Aug-09 18:52
professional«_Superman_»10-Aug-09 18:52 
GeneralRe: LNK errors while using an "extern "C"" function Pin
MozhdehQeraati10-Aug-09 19:48
MozhdehQeraati10-Aug-09 19:48 
GeneralRe: LNK errors while using an "extern "C"" function Pin
«_Superman_»10-Aug-09 19:54
professional«_Superman_»10-Aug-09 19:54 
GeneralRe: LNK errors while using an "extern "C"" function Pin
Cedric Moonen10-Aug-09 20:15
Cedric Moonen10-Aug-09 20:15 
QuestionReturn value from a funtion Pin
AkashAg10-Aug-09 18:06
AkashAg10-Aug-09 18:06 
AnswerRe: Return value from a funtion Pin
«_Superman_»10-Aug-09 18:41
professional«_Superman_»10-Aug-09 18:41 
GeneralRe: Return value from a funtion Pin
AkashAg10-Aug-09 18:46
AkashAg10-Aug-09 18:46 
GeneralRe: Return value from a funtion Pin
«_Superman_»10-Aug-09 18:47
professional«_Superman_»10-Aug-09 18:47 
AnswerRe: Return value from a funtion Pin
Stuart Dootson10-Aug-09 21:22
professionalStuart Dootson10-Aug-09 21:22 
QuestionTranslate Logical Drive to Physical Drive Pin
Bram van Kampen10-Aug-09 14:55
Bram van Kampen10-Aug-09 14:55 
AnswerRe: Translate Logical Drive to Physical Drive Pin
Randor 10-Aug-09 17:45
professional Randor 10-Aug-09 17:45 
You could use the IOCTL_STORAGE_GET_DEVICE_NUMBER[^] control code to obtain the physical drive and volume number.

For example:

#include <Winioctl.h>
VOID LogicalToPhysical(TCHAR *szDrive)
{
	CString szPhysical;
	HANDLE h = CreateFile(szDrive, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
	if(INVALID_HANDLE_VALUE != h)
	{
		STORAGE_DEVICE_NUMBER sd;
		DWORD dwRet;
		if(DeviceIoControl(h, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sd, sizeof(STORAGE_DEVICE_NUMBER), &dwRet, NULL))
		{
			szPhysical.Format(_T("\\\\.\\PhysicalDrive%d"), sd.DeviceNumber);
		}
		CloseHandle(h);
	}
}

//Usage:
LogicalToPhysical(_T("\\\\.\\\\C:"));


Note that this control code will fail to return correct information for mirrored and striped volumes. A more complete solution for these types of drives would be the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS[^] control code which will return an array of partitions for the drive.

Best Wishes,
-David Delaune
GeneralRe: Translate Logical Drive to Physical Drive [modified] Pin
Bram van Kampen11-Aug-09 11:09
Bram van Kampen11-Aug-09 11:09 
GeneralRe: Translate Logical Drive to Physical Drive Pin
Randor 11-Aug-09 13:06
professional Randor 11-Aug-09 13:06 
GeneralRe: Translate Logical Drive to Physical Drive Pin
Bram van Kampen12-Aug-09 8:31
Bram van Kampen12-Aug-09 8:31 
GeneralRe: Translate Logical Drive to Physical Drive Pin
Andy Belton24-Dec-11 21:37
Andy Belton24-Dec-11 21:37 

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.