why the function CopyFile(), GetModuleFileName(), etc works in dev and not in visual C++ 2008? the error result said that the function cannot convert char[] to LPCWSTR (what is that dude? :)) )
Bloodshed Dev-C++ is out of date and so it will not do the same checks against your code that M$ Visual Studio will. I would go with what M$VS says and say your code is wrong.
If you prefer the layout and feel of Dev-C++, I know that I do, then use the spin-off version found here: http://wxdsgn.sourceforge.net/
It's much more up to date with the C++ standard.
The problem is that VC++ defines UNICODE by default (which is a good thing), while MinGW doesn't. When this macro is defined, the Windows headers use the UTF-16 (or "wide", because it uses wider characters) versions of the functions. It's possible to force usage of the ANSI version regardless of whether UNICODE is defined by appending A to the identifier. For example: CopyFileA(). The equivalent for the wide version is CopyFileW().
Visual Studio comes now configured to produce Unicode builds. You are used to using char all over the place. That is bad when programming Windows. Whoever is teaching you Windows programming should have taught you about TCHAR, TEXT() and related topics.
Either change the project to Multybyte (not recommended), or start using TCHAR and TEXT():
As you can see, you can easily get TCHAR-friendly data types and variables. A proper Windows program in C/C++ should exhibit TCHAR only everywhere, except in parts that are COM-related because COM works only with Unicode strings. In here you'll be forced to use wchar_t and related data types, such as LPWSTR, LPCWSTR and BSTR.
EDIT: One more: OLESTR, LPOLESTR (I think I have seen these 2 before).
This way the Windows headers are good for either Multibyte or Unicode builds. Once TCHAR is defined, it is a matter of defining other types based on it, like LPTSTR (which becomes LPWSTR when compiling for Unicode), LPCTSTR, etc.
?? No difference, or I don't get your question. If your project is built for Multibyte, TCHAR == char exactly; if your project is built for Unicode, TCHAR == wchar_t exactly.
oh because, i'm a little bit confused about your answer before. you said:
You are used to using char all over the place. That is bad when programming Windows. Whoever is teaching you Windows programming should have taught you about TCHAR, TEXT() and related topics.
so i thought that TCHAR is a new type, but you said that char and TCHAR is the same so that makes me confused. but now, as long as i see, your purpose for using TCHAR is for "optional" usage, for example, if your code isused for unicode then TCHAR take "role" as wchar_t and for multybyte (ordinary project?) as char. am i right?
i'm a little bit curious about this:
#ifdef _UNICODE
is it means: "if unicode is defined" ? if so, why you're saying:
if your project is built for Unicode, TCHAR == wchar_t exactly.
edit: my question in bold, it looks confused before...
Throughout your program, if you use TCHAR, TEXT(), etc, then converting your program between multibyte and Unicode is merely a matter of #defining _UNICODE, as that definition will set TCHAR and all related types and functions to be the ANSI or wide versions.
hehe, my bad. :-( It should have been the other way around (#ifdef _UNICODE, then TCHAR is wchar_t and NOT char).
And OK, yes, there is a difference since I now understood your question: The Windows SDK is designed so it compiles for multibyte or Unicode. Basically, the way they do it is to define the TCHAR datatype conditionally as shown before. The other 2 main tricks are TEXT() (or _T()) for string literals and the function names. The function names are not function names: They are #define 's. The real function names end with A or W, depending on whether they are ANSI (multibyte) or Unicode (wide chars).