|
-
Sep 3rd, 2001, 04:12 PM
#1
Thread Starter
Addicted Member
API problems
Just getting learning about API calls- any idea how to fix the problems in this code? I am trying the count the number of files in a directory....
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
LPWIN32_FIND_DATA Found;
HANDLE hFile;
BOOL Retval;
int fileCount = 0;
const unsigned char path [] = {"C:\\Documents and Settings\\Administrator\\My Documents\\*.*"};
hFile = FindFirstFile(path, Found);
//Check for an NVALID_HANDLE_VALUE
if (hFile == 0)
MessageBox (NULL, TEXT ("Error File Non Existent"), TEXT ("HelloMsg"), 0) ;
do{
//increment the count of files present
if(Found->dwFileAttributes == 16 || Found->dwFileAttributes == 32)
fileCount ++;
Retval = FindNextFile(hFile, Found);
}while (Retval != 0);
FindClose (hFile);
//Don't think I can do this can I?
MessageBox (NULL, TEXT ("Files Present In Directory" && fileCount), TEXT ("HelloMsg"), 0) ;
return (0);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|