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

C / C++ / MFC

 
AnswerRe: Displaying Text in System Tray Pin
douglasjordan30-Sep-05 4:47
douglasjordan30-Sep-05 4:47 
GeneralRe: Displaying Text in System Tray Pin
hairam1-Oct-05 6:32
hairam1-Oct-05 6:32 
GeneralRe: Displaying Text in System Tray Pin
douglasjordan1-Oct-05 8:12
douglasjordan1-Oct-05 8:12 
Questionrecursive function to search folder contents Pin
dharani29-Sep-05 18:32
dharani29-Sep-05 18:32 
AnswerRe: recursive function to search folder contents Pin
ThatsAlok29-Sep-05 18:59
ThatsAlok29-Sep-05 18:59 
AnswerRe: recursive function to search folder contents Pin
benjnp30-Sep-05 6:42
benjnp30-Sep-05 6:42 
QuestionWM_COPYDATA Pin
Nishad S29-Sep-05 18:24
Nishad S29-Sep-05 18:24 
AnswerRe: WM_COPYDATA Pin
ThatsAlok29-Sep-05 22:12
ThatsAlok29-Sep-05 22:12 
AnswerRe: WM_COPYDATA Pin
douglasjordan30-Sep-05 11:16
douglasjordan30-Sep-05 11:16 
QuestionHelp !!! Cannot install Visual Studio 6 Pin
erajsri29-Sep-05 17:53
erajsri29-Sep-05 17:53 
QuestionEncoding Pin
Member 216100429-Sep-05 17:17
Member 216100429-Sep-05 17:17 
QuestionAccess 97 Pin
AHawk29-Sep-05 16:40
AHawk29-Sep-05 16:40 
QuestionConversion between Hex and Character Pin
Member 78215429-Sep-05 14:51
Member 78215429-Sep-05 14:51 
QuestionRuntime for Accessing Jet files Pin
Joe Woodbury29-Sep-05 11:52
professionalJoe Woodbury29-Sep-05 11:52 
AnswerRe: Runtime for Accessing Jet files Pin
Graham Bradshaw29-Sep-05 13:46
Graham Bradshaw29-Sep-05 13:46 
GeneralRe: Runtime for Accessing Jet files Pin
Joe Woodbury29-Sep-05 13:57
professionalJoe Woodbury29-Sep-05 13:57 
Questionsort a struct array Pin
petesfish29-Sep-05 11:41
petesfish29-Sep-05 11:41 
hi, maybe someone can help me to with my code.
I need to sort some tchars which are stored in a struct array by "szNtDeviceName". I tried to use qsort but I'm a noob in C++ and not familiar with pointers, so I can't get it running.

here is the code:

#define _WIN32_WINNT 0x0501

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <cstring>
#include <string.h>
#include <stdlib.h>

#define BUFSIZE MAX_PATH
#define MAXDRIVELETTERS 25

struct DriveInfo
{
bool bIsValidLogicalDrive;
TCHAR szDriveLetter[4];
TCHAR szVolumeName[BUFSIZE];
TCHAR szNtDeviceName[BUFSIZE];
};

int compare( const void *, const void * );

int _tmain(int argc, _TCHAR* argv[])
{
BOOL bFlag;
TCHAR Buf[BUFSIZE]; // temporary buffer for volume name
TCHAR Drive[] = TEXT("c:\\"); // template drive specifier
TCHAR Temp[] = TEXT("c:\\"); // template drive specifier
TCHAR I; // generic loop counter
int i = 0;
char szNtDeviceNameTemp[BUFSIZE]; // temporary buffer for NTDeviceName
int iVolumeMountPoints = 0;

DriveInfo* Arr = new DriveInfo[MAXDRIVELETTERS];

// Walk through legal drive letters, skipping floppies.
for (I = TEXT('c'); I < TEXT('z'); I++ ){

// Stamp the drive for the appropriate letter.
Drive[0] = I;

//LogicalDrivesArray[i].szDriveLetter=I;

bFlag = GetVolumeNameForVolumeMountPoint(
Drive, // input volume mount point or directory
Buf, // output volume name buffer
BUFSIZE // size of volume name buffer
);

if (bFlag){
//found MountPoint add them to array
lstrcpy(Arr[iVolumeMountPoints].szVolumeName, Buf);
Arr[iVolumeMountPoints].bIsValidLogicalDrive = true;

// remove end backslash for query
Temp[0] = Drive[0];
Temp[1] = Drive[1];
Temp[2] = '\0';

lstrcpy(Arr[iVolumeMountPoints].szDriveLetter, Temp);

// get NTDeviceName from DriveLetter
if (QueryDosDevice (Temp, szNtDeviceNameTemp, MAX_PATH)){
lstrcpy(Arr[iVolumeMountPoints].szNtDeviceName, szNtDeviceNameTemp);
}

iVolumeMountPoints++;
}
}

// unsing quicksort to sort by .szNtDeviceName
qsort( Arr, sizeof(Arr[0].szNtDeviceName ), sizeof(Arr[0]), compare );


if (iVolumeMountPoints>0){
printf("%i VolumeMountPoint(s) found\n", iVolumeMountPoints);
for (i=0; i<iVolumeMountPoints; i++){
//if (Arr[i].bIsValidLogicalDrive){
printf("\n%s %s %s", Arr[i].szDriveLetter, Arr[i].szVolumeName, Arr[i].szNtDeviceName);
//}
}
}
else{
printf("no VolumeMountPoint found");
}

//cleanup array
delete[] Arr;

return 0;
}

int compare( const void *a, const void *b )
{
DriveInfo **pa = (DriveInfo **) a, **pb = (DriveInfo **) b;

/* Compare */
return strcmp( (*pa)->szNtDeviceName, (*pb)->szNtDeviceName );
}



AnswerRe: sort a struct array Pin
PJ Arends29-Sep-05 12:18
professionalPJ Arends29-Sep-05 12:18 
QuestionCalling VB Pin
benjnp29-Sep-05 11:30
benjnp29-Sep-05 11:30 
AnswerRe: Calling VB Pin
vikas amin30-Sep-05 1:54
vikas amin30-Sep-05 1:54 
GeneralRe: Calling VB Pin
benjnp30-Sep-05 6:36
benjnp30-Sep-05 6:36 
Questionregistry question Pin
Ann6629-Sep-05 7:59
sussAnn6629-Sep-05 7:59 
AnswerRe: registry question Pin
David Crow29-Sep-05 9:27
David Crow29-Sep-05 9:27 
AnswerRe: registry question Pin
Graham Bradshaw29-Sep-05 13:48
Graham Bradshaw29-Sep-05 13:48 
QuestionIDC_BUTTON undeclared identifier ! Pin
sunguy29-Sep-05 7:19
sunguy29-Sep-05 7: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.