Link to home
Start Free TrialLog in
Avatar of DarrinE
DarrinE

asked on

GetLogicalDriveString

Would someone be kind enough to properly translate the following into C for me (I cant program MFC) - I've tried bu keep making a mess of it <s>

      DWORD Check;
    char buffer[30];
      CStringArray l_saDrives;
    char chTemp[10];
      int Count = 0;

      Check=GetLogicalDriveStrings(20,buffer);

      ZeroMemory(chTemp, 10);

      for(int i = 0; i < Check; i++)
      {
            if(buffer[i] == 0)
            {
             l_saDrives.Add(chTemp);
             ZeroMemory(chTemp, 10);
             Count = 0;
            }
            else
            chTemp[Count++] = buffer[i];

      }
     
      for(i = 0; i < l_saDrives.GetSize(); i++)
      {
      AfxMessageBox(l_saDrives[i]);
      }

DarrinE
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DarrinE
DarrinE

ASKER

Thanks jkr - finishing with this for an A grade answer

for(i = 0; i < l_saDrives.GetSize(); i++)
{
AfxMessageBox(l_saDrives[i]);
}

DarrinE
Ooops, have overseen this ;-)

i = 0;
for ( ;;)
{
      if ( !apszDrives [ i]) break;
      MessageBox ( NULL, apszDrives [ i++], "Drive found", MB_OK | MB_ICONINFORMATION);
}      
Avatar of DarrinE

ASKER

I am greatful for the prompt response - I have not tried it - but it looks fine - tell me how can I tell the maximum size of apszDrives [ i]

Many thanks

DarrinE
The maximum size is (should always) be 26 - there aren't any more letters in the alphabet ;-)
Avatar of DarrinE

ASKER

OK - I get it - but how can I tell how many arrays are in apszDrives ?
while ( *pc)
{
apszDrives [ i++] = pc;

pc = memchr ( pc + 1, '\0', 256);

if ( !pc) break;

pc++;
}

When the loop is finished, 'i' holds the number of drives...
Avatar of DarrinE

ASKER

Many thanks

Have a good one <!>

Send me a private email and I'll send you a fix for the loveletter virus I've just finished - does not do the server - just the local PC

dwe@primus.com.au
Not needed - our sendmail gateway (Linux) simply kicks all of them ;-)