Click here to Skip to main content
15,913,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC MSG Pin
David Crow29-Sep-04 4:25
David Crow29-Sep-04 4:25 
GeneralRe: MFC MSG Pin
ANDYFA29-Sep-04 6:59
ANDYFA29-Sep-04 6:59 
GeneralRe: MFC MSG Pin
David Crow29-Sep-04 7:17
David Crow29-Sep-04 7:17 
GeneralRe: MFC MSG Pin
ANDYFA29-Sep-04 7:25
ANDYFA29-Sep-04 7:25 
GeneralRe: MFC MSG Pin
David Crow29-Sep-04 7:30
David Crow29-Sep-04 7:30 
GeneralRe: MFC MSG Pin
ANDYFA29-Sep-04 7:39
ANDYFA29-Sep-04 7:39 
GeneralRe: MFC MSG Pin
David Crow29-Sep-04 7:43
David Crow29-Sep-04 7:43 
GeneralReading from the port Pin
mithuna29-Sep-04 1:14
mithuna29-Sep-04 1:14 
GeneralDataBase management - MS Excel Pin
Daniel Kanev29-Sep-04 1:08
Daniel Kanev29-Sep-04 1:08 
GeneralRe: DataBase management - MS Excel Pin
David Crow29-Sep-04 4:49
David Crow29-Sep-04 4:49 
QuestionHow to start a PC/Application from Program Pin
Billar29-Sep-04 0:43
Billar29-Sep-04 0:43 
AnswerRe: How to start a PC/Application from Program Pin
22491729-Sep-04 2:04
22491729-Sep-04 2:04 
GeneralRe: How to start a PC/Application from Program Pin
vcplusplus29-Sep-04 3:12
vcplusplus29-Sep-04 3:12 
GeneralRe: How to start a PC/Application from Program Pin
Billar30-Sep-04 2:33
Billar30-Sep-04 2:33 
AnswerRe: How to start a PC/Application from Program Pin
David Crow29-Sep-04 4:52
David Crow29-Sep-04 4:52 
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 

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.