On Jul 16, 6:45 pm, Michael Reichenbach <Reichenb...@di scardmail.com>
wrote:
Ok. You got me. :) It`s was not the real code. I always try to cut down
my problem to a minimum so it`s more easy to figure out.
Here is a new example code. I tested it. It works in DevCpp but not in
Visual Studio.
#include <stdlib.h>
#include <windows.h>
int main()
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(" c://test", &FindFileDat a);
system("PAUSE") ;
return EXIT_SUCCESS;
}- Hide quoted text -
- Show quoted text -
Do you have UNICODE (or maybe it's _UNICODE, I always forget)
defined? There is no way that code should fail under windows unless
FindFirstFile is expecting a wide character string, and it shouldn't
expect a wide string unless you have _UNICODE or UNICODE defined.
See if the following works:
int main()
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(L "c://test", &FindFileDat a); //notice
the L
system("PAUSE") ;
return EXIT_SUCCESS;
}
Venturing into off-topicness, but assuming this fixes it, one possible
reason it works with one compiler but not the other could be that
you're defining the preprocessor symbol through your project settings
(Project -Project Propert -C++ -Preprocessor), which obviously
GCC doesn't know about.
The way windows functions work is that there's always 2 versions of
most WinApi functions. One ends with an 'A' and expects char*, the
other ends with a 'W' and expects wchar_t*. Then, based on the value
of various preprocessor symbols, a version of every function with
neither A nor W is #defined to the A or W version. So if you have
UNICODE defined, FindFirstFile actually is FindFirstFileW( wchar_t*,
WIN_32_FIND_DAT A*), and if you don't have UNICODE defined,
FindFirstFile actually is FindFirstFileA( char*, WIN32_FIND_DATA *).
The same is true for many other functions as well.