Gus Vincent Dato wrote:
> hi.
>
> thanks.
>
> actually, what i need is the string which is returned by the FindFirstFile.
> and if it did not find any files, i will just print error on the screen.
>
> thanks again.
Unless you are interested in Unicode programming (which is useful to
know how to do BUT requires using a whole different set of functions -
typically non-Standard), I recommend disabling Unicode compiles.
Right-click on your Project, select Properties..., Locate the option in
the General options that says "Unicode" and change it so it doesn't
compile in Unicode support into the application (ANSI is what you want).
This should fix most of your problems.
class DirInfo
{
private:
HANDLE hFind;
WIN32_FIND_DATA Data;
public:
DirInfo()
{
hFind = NULL;
}
~DirInfo()
{
if (hFind != NULL) FreeDirInfo();
}
int FFF(TCHAR *DirName)
{
hFind = FindFirstFile(DirName, &Data) ;
return (hFind != INVALID_HANDLE_VALUE);
}
char *GetCurrFile(DirInfo &DestInfo)
{
return DestInfo.Data.cFileName;
}
int FreeDirInfo()
{
CloseHandle(hFind);
}
};
int main()
{
DirInfo MyInfo;
if (!MyInfo.FFF("somedir"))
{
printf("ERROR");
exit(1);
}
printf("%s\n", MyInfo.GetCurrFile());
return 0;
}
Or something like that. Please try to show some effort at trying to
figure things out. 'Unicode' should have been a hint to search Google:
http://en.wikipedia.org/wiki/Unicode
http://www.google.com/search?q=vc%2b%2b+turn+off+unicode
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/