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

C / C++ / MFC

 
AnswerRe: strstr in managed applications Pin
Nish Nishant9-Dec-05 10:57
sitebuilderNish Nishant9-Dec-05 10:57 
QuestionRogueWave ToolsVC? Pin
Ed K9-Dec-05 10:29
Ed K9-Dec-05 10:29 
QuestionFindWindow Word2003 problem Pin
rem-c9-Dec-05 10:29
rem-c9-Dec-05 10:29 
AnswerRe: FindWindow Word2003 problem Pin
sun_shb9-Dec-05 20:40
sun_shb9-Dec-05 20:40 
GeneralRe: FindWindow Word2003 problem Pin
rem-c10-Dec-05 4:28
rem-c10-Dec-05 4:28 
QuestionIdentify the CD rom drive Pin
NYTSX9-Dec-05 10:09
NYTSX9-Dec-05 10:09 
AnswerRe: Identify the CD rom drive Pin
Alex Orovetskiy9-Dec-05 10:49
Alex Orovetskiy9-Dec-05 10:49 
AnswerRe: Identify the CD rom drive Pin
Axter9-Dec-05 11:49
professionalAxter9-Dec-05 11:49 
You can call GetDriveType API function to determine if it's a CD Rom.

Check out the following wrapper class:

#include <windows.h>

#include <vector>
#include <string>

#include <iostream>


using namespace std;

class DriveInfo
{
public:
DriveInfo()
{
char* buffer = 0;
size_t bsize = 0;
getDriveLetters(bsize,buffer);
parseDriveLetters(bsize,buffer);
delete [] buffer;
}

size_t NumDrives() const
{ return mDrives.size();}

std::string DriveName(size_t index) const
{ return mDrives[index]; }

char DriveLetter(size_t index) const
{ return mDrives[index][0]; }

DWORD DriveType(const std::string& driveName) const
{ return ::GetDriveType(driveName.c_str()); }
private:
void getDriveLetters(size_t& bufferSize, char*& driveStrings) const
{
bufferSize = MAX_PATH;

driveStrings = new char[bufferSize];

bool gotDriveNames = false;
while (!gotDriveNames)
{
DWORD pos = ::GetLogicalDriveStrings((DWORD)bufferSize, driveStrings);

if (pos > bufferSize)
{
bufferSize *= 2;
delete [] driveStrings;
}
else
{
gotDriveNames = true;
}
}
}

void parseDriveLetters(size_t size, const char* buffer)
{
std::string s(buffer, size);
std::string driveString;
for (size_t i=0; i<size; i++)
="" {
="" if="" (s[i]="=" 0)
="" (!drivestring.empty())="" mdrives.push_back(drivestring);
="" drivestring="" ;
="" }
="" else
="" +="s[i];
" }

="" std::vector<std::string=""> mDrives;
};


Example usage:
int main()
{
DriveInfo di;
for (size_t i=0; i
GeneralRe: Identify the CD rom drive Pin
Alex Orovetskiy9-Dec-05 22:29
Alex Orovetskiy9-Dec-05 22:29 
AnswerRe: Identify the CD rom drive Pin
NYTSX11-Dec-05 9:54
NYTSX11-Dec-05 9:54 
GeneralRe: Identify the CD rom drive Pin
ThatsAlok11-Dec-05 21:27
ThatsAlok11-Dec-05 21:27 
Questionnew and delete operators size element Pin
lastgen9-Dec-05 9:53
lastgen9-Dec-05 9:53 
AnswerRe: new and delete operators size element Pin
Chris Losinger9-Dec-05 10:16
professionalChris Losinger9-Dec-05 10:16 
GeneralRe: new and delete operators size element Pin
lastgen9-Dec-05 10:31
lastgen9-Dec-05 10:31 
GeneralRe: new and delete operators size element Pin
Tim Smith11-Dec-05 6:44
Tim Smith11-Dec-05 6:44 
AnswerRe: new and delete operators size element Pin
sun_shb9-Dec-05 20:43
sun_shb9-Dec-05 20:43 
GeneralRe: new and delete operators size element Pin
lastgen16-Dec-05 17:33
lastgen16-Dec-05 17:33 
Question[Message Deleted] Pin
Gunn3179-Dec-05 8:51
Gunn3179-Dec-05 8:51 
AnswerRe: Obtaining properties of an executable Pin
Chris Losinger9-Dec-05 8:54
professionalChris Losinger9-Dec-05 8:54 
GeneralRe: Obtaining properties of an executable Pin
Gunn31712-Dec-05 11:17
Gunn31712-Dec-05 11:17 
GeneralRe: Obtaining properties of an executable Pin
Gunn31713-Dec-05 4:44
Gunn31713-Dec-05 4:44 
Questionhow can i tell Pin
Umair Ahmad khan9-Dec-05 7:31
Umair Ahmad khan9-Dec-05 7:31 
AnswerRe: how can i tell Pin
Dominik Reichl9-Dec-05 10:45
Dominik Reichl9-Dec-05 10:45 
QuestionREG_QWORD max length??? Pin
Supriya Tonape9-Dec-05 7:24
Supriya Tonape9-Dec-05 7:24 
AnswerRe: REG_QWORD max length??? Pin
Jörgen Sigvardsson9-Dec-05 9:29
Jörgen Sigvardsson9-Dec-05 9:29 

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.