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=GetLogicalDriveStrin gs(20,buff er);
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
DWORD Check;
char buffer[30];
CStringArray l_saDrives;
char chTemp[10];
int Count = 0;
Check=GetLogicalDriveStrin
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ooops, have overseen this ;-)
i = 0;
for ( ;;)
{
if ( !apszDrives [ i]) break;
MessageBox ( NULL, apszDrives [ i++], "Drive found", MB_OK | MB_ICONINFORMATION);
}
i = 0;
for ( ;;)
{
if ( !apszDrives [ i]) break;
MessageBox ( NULL, apszDrives [ i++], "Drive found", MB_OK | MB_ICONINFORMATION);
}
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
Many thanks
DarrinE
The maximum size is (should always) be 26 - there aren't any more letters in the alphabet ;-)
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...
{
apszDrives [ i++] = pc;
pc = memchr ( pc + 1, '\0', 256);
if ( !pc) break;
pc++;
}
When the loop is finished, 'i' holds the number of drives...
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
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 ;-)
ASKER
for(i = 0; i < l_saDrives.GetSize(); i++)
{
AfxMessageBox(l_saDrives[i
}
DarrinE