Eric Smith
May 19th, 1999, 04:06 PM
Ok, I am here to show my ignorance again.
Below is some code which I wrote to experiment with opening Windows directories so that I may do things with them, like examine all files within a directory.
#include <list>
#include <iostream>
#include <windows.h>
void main()
{
char bogus[256]="c:\\";
HANDLE hDir = CreateFile (bogus,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if((int)hDir==-1)
{
char errorbuf[256]="";
DWORD e=GetLastError();
DWORD f=FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,e,NULL,errorbuf,255,NULL);
if(f)
std::cout << errorbuf << "\n";
}
}
The program runs and will print out "The parameter is incorrect."
Of course I don't know which parameter is "The" parameter.
It would seem to me that this should open the "C:\" directory and hDir will be some useful value. I'm stumped.
Perhaps I should be chasing down another path. I began my search by looking for a CDir class. I could not find one. Should I be able to indeed grab ahold of any directory and then successfully traverse that directory, then I would be happy to write a CDir class.
Anyway, this is giving me a headache and I think someone else must have run into this problem before. I just want a successful handle on an existing windows directory.
Thanks.
Eric Smith
mentoplat@hotmail.com
Below is some code which I wrote to experiment with opening Windows directories so that I may do things with them, like examine all files within a directory.
#include <list>
#include <iostream>
#include <windows.h>
void main()
{
char bogus[256]="c:\\";
HANDLE hDir = CreateFile (bogus,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if((int)hDir==-1)
{
char errorbuf[256]="";
DWORD e=GetLastError();
DWORD f=FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,e,NULL,errorbuf,255,NULL);
if(f)
std::cout << errorbuf << "\n";
}
}
The program runs and will print out "The parameter is incorrect."
Of course I don't know which parameter is "The" parameter.
It would seem to me that this should open the "C:\" directory and hDir will be some useful value. I'm stumped.
Perhaps I should be chasing down another path. I began my search by looking for a CDir class. I could not find one. Should I be able to indeed grab ahold of any directory and then successfully traverse that directory, then I would be happy to write a CDir class.
Anyway, this is giving me a headache and I think someone else must have run into this problem before. I just want a successful handle on an existing windows directory.
Thanks.
Eric Smith
mentoplat@hotmail.com