Website Design United States, Website Design California, Website Designing United States, Website Designing California

Windows - Creating a FIFO queue with a Directory - C++

This is the counter part for the Linux version as the application it was orginally created for runs on both Linux and Windows.

As with the Linux version the error checking in this example is lacking, but it will give you the idea.

WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
char DirSpec[MAX_PATH];

strncpy(DirSpec,PS->GetPath()->c_str(), strlen(PS->GetPath()->c_str())+1);
strncat(DirSpec,"\\*",3);

hFind = FindFirstFile(DirSpec,&FindFileData);
if (hFind == INVALID_HANDLE_VALUE) return NULL;
else {

// Move File point past "." and "..", if no more files, return NULL
if (FindNextFile(hFind,&FindFileData) == 0) return NULL;
if (FindNextFile(hFind,&FindFileData) == 0) return NULL;

DWORD _creationTime = FindFileData.ftCreationTime.dwHighDateTime;
WIN32_FIND_DATA _tf = FindFileData;

// Compare the Creation time of _tf to that of the current FP
// if the FP is older, set _tf to FP, else do nothing
while (FindNextFile(hFind, &FindFileData) != 0) {
if (_creationTime > FindFileData.ftCreationTime.dwHighDateTime) {
_creationTime = FindFileData.ftCreationTime.dwHighDateTime;
_tf = FindFileData;
}
}
return _tf.cFileName;
}

 
WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com