Hello everyone,
I'm into writting a project ,that's all about dealing with directories and more specificly to code something that finally well work as"windows command prompt" in standard console....
i Got alot help from the experts here & got alot progressed, But a bug has occured in between:
yestreday i got announced that we've got to use the WIN32_FIND_DATA stuct and use it's members to deal with directories only. To be given more help the teacher wrote down this code for us :

bool isdirecory(wchar_t *temp)
    WIN32_FIND_DATA   filedata;
    HANDLE h.search;
    h.search=FindFirstFile(temp, & filedata);
       if (filedata.dwattributes==16)
             return true;
             return false;

this function supossedly is to identify whether the variable "temp" is a directory in the system or not !
But the fact is that i cant realize what process is going on. all my searches about this stuct looks quite wierd i cant make head or tails of. ccan any one pppplllleeeaassse clarify for me what do the items above, each one of them, do ? .....as well as letting me know how i can pass an argument to this function ?, is the argument "wchar_t" the address we're gonna check its validity ...or what is it at all ? arent all addresses in char* mode ?... how to modify them if yes ??? ....i feel totally mixed up with these few lines ! any helps will highly be appriciated !
Thanx in advance
Mahsa M
student of computer engeneering **in the very begining of course**

8 Years
Discussion Span
Last Post by Salem

Thank u very much,
yeah, i alreday had taken a look at those MSDN pages, i know that 16 means the given address is a true directory.
but what still remains unsolved is that i don know how to pass an argument to this function.
for example if i'm supposed to detemin if "C:\program files\Firefox" is one of the existing directories of my computer, how can i use this function? .. i cant change it into wchar_t* !..my searches reveal confusing results !
would u write me a comprehensive example , with datas given, so that i betterly undersatnd? thank u very much.


Well in windows, wchar_t should be TCHAR (scroll down to the examples in the links)

So perhaps isdirecory( TEXT("C:\\program files\\Firefox") );


Thank u big time !
it now seems like i can be hopeful to get a nerve relief about performing my project.
So, Does the Function TEXT(qoate ) change a char* to wchar_t ??
it seems like it does so, but it does it abit more complicated than i thought at first...what does the term "qoate" exactly mean here ??
..when i use the code below:

char* str="C:\WINDOWS";
wchar_t* longstr=TEXT(str);

im given the following error:

error C2065: 'Lstr' : undeclared identifier

so...how can i change it in a way that i be able to pass a string to the TEXT argument ?
..i need it since the user is to enter the directory address, and i am to determin wether he's entered wrong or write ?
Tanx alot

Edited by mike_2000_17: Fixed formatting


TEXT isn't a function, it's a macro.
So it's limited to "strings"

It's not a good idea to try to keep both forms in your program, except for when you absolutely have to choose one specific form for a particular case. Even then, try to minimise the scope so it doesn't pollute the rest of your code.

For example, you might do

TCHAR *str = TEXT("C:\\Windows");
TCHAR *s2 = str;

Where you might have previously used strcpy to copy a string, you would use _tcscpy() instead, which does the right thing depending on whether you compile for ANSI or UNICODE.

This is a handy list-on-a-page of all the mapped API calls.

However, this being C++ (I assume, since this is the forum you posted on), you should start to look at the wide character equivalent of std::string to do most of the work for you.
Lets see how long it takes your teacher to enter the real world of C++.


Thank u Salem alot !!
yes, you're right, that would be bothering to try to use the both forms of wchar_t* and char*, so instead i'll try to deal with merely unicode charactors.
The link you put for me is surprisingly filtered :| .. i'll then try connections through different ways to see whether i can open it or not ?.. would u do me a favor and copy them for me on the page here ?...i'll highly appriciate it.

one more critical question:
Does WIN32_find_data structure provide me with something that i need to use to get a list of files & folders in a directory ? like what <Dir> does in windows... i viwed the data memebres of the struct, i couldnt find one...
If this struct is of no help, what recomandations do u have ??

ps-Yeah, u're right...Perhaps there's still long way till we learn wholy about c++, but the point was that i didnt know to which world ( c or c++) my question exactly refers! ( even worse!) :D i'm almost lost between my scattered knowledge of both worlds !
Thank uuuuu greatly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.