Click here to Skip to main content
15,891,473 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to start a PC/Application from Program Pin
Billar30-Sep-04 2:18
Billar30-Sep-04 2:18 
QuestionAlternative to SetCursorPos? Pin
Zee man28-Sep-04 23:42
Zee man28-Sep-04 23:42 
AnswerRe: Alternative to SetCursorPos? Pin
Budric B.29-Sep-04 3:24
Budric B.29-Sep-04 3:24 
GeneralRe: Alternative to SetCursorPos? Pin
Zee man29-Sep-04 7:58
Zee man29-Sep-04 7:58 
GeneralImage List and managed extensions problem Pin
sv2george28-Sep-04 23:33
sv2george28-Sep-04 23:33 
GeneralRe: Image List and managed extensions problem (Dirty solution!) Pin
sv2george29-Sep-04 0:50
sv2george29-Sep-04 0:50 
QuestionHow to get volume letter of a USB disk ? Pin
Amanda Davis28-Sep-04 23:25
Amanda Davis28-Sep-04 23:25 
AnswerRe: How to get volume letter of a USB disk ? Pin
JimmyRopes29-Sep-04 3:23
professionalJimmyRopes29-Sep-04 3:23 
I copied this from a library routine I wrote to illustrate the technique. In my case I was only looking for fixed drives where I think you would be looking for removable drives. I am not sure, since it was a long time ago when I wrote the code, but I think I remember the USB drives coming up as removable. You will have to determine that for yourself as I am not 100% sure.

DRIVE_UNKNOWN The drive type cannot be determined.
DRIVE_NO_ROOT_DIR The root path is invalid. For example, no volume is mounted at the path.
DRIVE_REMOVABLE The disk can be removed from the drive.
DRIVE_FIXED The disk cannot be removed from the drive.
DRIVE_REMOTE The drive is a remote (network) drive.
DRIVE_CDROM The drive is a CD-ROM drive.
DRIVE_RAMDISK The drive is a RAM disk.

You may want to start at iDrive = 2 and MAX_DISKS = 24 to bypass the A: and B: drives which are removable but usually floppy disks.

Then again for completeness you may want to interrogate the A: and B: drives to determine by some other means if the A: and B: drives are floppy or USB drives.

I don't know if you are targeting clients capable of sophisticated configurations or the run of the mill PC that was assembled when bought and whose configuration has not been modified.

You can change the countof, a macro used to get the max count of characters in a TCHAR array, to sizeof if you also change the TCHAR to char in the _DRIVES structure.

You may not want to generate an stl::vector so you may have to cut and paste into your code.

// STL includes
#include <vector>
#include <algorithm>
using namespace std;

#include <tchar.h>
#include <strstrea.h>

#ifndef __COUNT_OF__
#define __COUNT_OF__
#define countof(x) (sizeof(x)/sizeof((x)[0]))
#endif // #ifndef __COUNT_OF__

#ifndef _DRIVES_
#define _DRIVES_
typedef struct _DRIVES{
TCHAR szDrive[4];
TCHAR szLabel[64];
}DRIVES;
#endif // #ifdef _DRIVES_

#define MAX_DISKS 26

char DiskLetters[MAX_DISKS][4]={
"A:\\", "B:\\", "C:\\", "D:\\", "E:\\", "F:\\",
"G:\\", "H:\\", "I:\\", "J:\\", "K:\\", "L:\\",
"M:\\", "N:\\", "O:\\", "P:\\", "Q:\\", "R:\\",
"S:\\", "T:\\", "U:\\", "V:\\", "W:\\", "X:\\",
"Y:\\", "Z:\\"
};

int CUtil::AcquireDiskPartitions(vector<DRIVES>& vDrives){
int iDrives = 0;
char szVolumeName[128] ;
char szFileSystem[48];
DWORD dwVolumeSerialNumber = 0;
DWORD dwMaxFileName = 0;
DWORD dwFileSystem = 0;
DRIVES drvItem;
ostrstream strmDrive(drvItem.szDrive, countof(drvItem.szDrive));
ostrstream strmLabel(drvItem.szLabel, countof(drvItem.szLabel));

vDrives.clear();
for (int iDrive = 0; iDrive < MAX_DISKS; iDrive++){
if (GetDriveType(DiskLetters[iDrive]) == DRIVE_FIXED){
GetVolumeInformation(DiskLetters[iDrive],
szVolumeName,
sizeof(szVolumeName),
&dwVolumeSerialNumber,
&dwMaxFileName,
&dwFileSystem,
szFileSystem,
sizeof(szFileSystem));

strmDrive.seekp(0);
strmDrive << DiskLetters[iDrive] << ends;

strmLabel.seekp(0);
strmLabel << szVolumeName << ends;

vDrives.push_back(drvItem);
iDrives++;
}
}
return iDrives;
}
GeneralHelp me,please! the parameter nEscape Pin
Guoguor28-Sep-04 22:49
Guoguor28-Sep-04 22:49 
GeneralRe: Help me,please! the parameter nEscape Pin
Sujan Christo28-Sep-04 23:19
Sujan Christo28-Sep-04 23:19 
GeneralNeed help to understand the MAKE utility in VS.Net. Pin
Link260028-Sep-04 22:21
Link260028-Sep-04 22:21 
GeneralRe: Need help to understand the MAKE utility in VS.Net. Pin
Andrew Walker29-Sep-04 2:30
Andrew Walker29-Sep-04 2:30 
GeneralText Editors developed in VC++ Pin
SVPG28-Sep-04 22:14
SVPG28-Sep-04 22:14 
GeneralProblem using Visual Studio.Net 03 in command-line prompt. Pin
Link260028-Sep-04 22:11
Link260028-Sep-04 22:11 
GeneralRe: Problem using Visual Studio.Net 03 in command-line prompt. Pin
Sujan Christo28-Sep-04 23:14
Sujan Christo28-Sep-04 23:14 
GeneralQuestion about compiling a driver Pin
gamitech28-Sep-04 21:42
gamitech28-Sep-04 21:42 
GeneralQuestion about compiling a driver Pin
gamitech28-Sep-04 21:38
gamitech28-Sep-04 21:38 
GeneralTrigger an event in a COM addin Pin
Anthony_Yio28-Sep-04 20:29
Anthony_Yio28-Sep-04 20:29 
QuestionHow to enable and disable a device driver by using VC or BC? Pin
tsung-yu28-Sep-04 20:28
tsung-yu28-Sep-04 20:28 
AnswerRe: How to enable and disable a device driver by using VC or BC? Pin
22491728-Sep-04 20:41
22491728-Sep-04 20:41 
Generalparser Pin
Anonymous28-Sep-04 19:53
Anonymous28-Sep-04 19:53 
GeneralRe: parser Pin
Anonymous28-Sep-04 19:54
Anonymous28-Sep-04 19:54 
GeneralRe: parser Pin
Anthony_Yio28-Sep-04 20:24
Anthony_Yio28-Sep-04 20:24 
GeneralRe: parser Pin
Yulianto.28-Sep-04 20:01
Yulianto.28-Sep-04 20:01 
GeneralRe: parser Pin
Alan Chambers29-Sep-04 10:43
Alan Chambers29-Sep-04 10:43 

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.