Advertisement

"WinMain()" as "_tWinMain()"

Started by January 20, 2003 09:49 AM
5 comments, last by mdias 21 years, 10 months ago
Hi, I was exploring a DX9 sample "StagedPeer" and I saw in there the function "_tWinMain()" what is this? I can only see a diference between "WinMain()" and "_tWinMain()", the _tWinMain() doesn''t take the hPrevInstance argument, but is that the only diference ??? KaMiKaZe
Well, to answer you question I have no idea. From everything I read the hPreInstance var is a left over from old windows programming and was left in for backwards compadability. Though I''d give me 2 cents.
Advertisement
_tWinMain actually does take the hPrevInstance parameter, but that parameter isn''t used.

_tWinMain is just a #define to WinMain (in TCHAR.h).

There is no difference between the two.
_tWinMain is defined to WinMain if UNICODE is not defined, and to wWinMain if it is. its purpose is to let you write code that will build both under ansi and under unicode.
I think you are supposed to use _tWinMain for when your app is going to be supporting unicode. Something to do with the transition between 32 it windows and 64 bit windows. Using _tWinMain is compatible with both windows, so its safer. Although im not too sure about this. I remember reading somethinglike this on msdn. Im sure if you search there, something will come up.

:::Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile
[size=2]aliak.net
It''s nothing to do with 32- / 64- bit Windows.

It''s just a convienice if you want to support both the ANSI (multi-byte) and Unicode (wide character) character sets.

In tchar.h, _tWinMain is #defined to WinMain if UNICODE is not #defined, and to wWinMain if it is.

The different between WinMain and wWinMain is that WinMain takes an LPSTR (i.e. char *) as the last argument (the command-line) while wWinMain takes an LPWSTR (i.e. wchar_t *). _tWinMain, then, takes an LPTSTR (which is defined in tchar.h again to be either LPSTR or LPWSTR, depending on whether UNICODE is defined).

Wow, I hope that didn''t confure you more Just suffice to say that _tWinMain is something you use when you''re worried about Unicode support.

If I had my way, I''d have all of you shot! codeka.com - Just click it.

Advertisement
Okay, thanks guys I understand that now

KaMiKaZe

This topic is closed to new replies.

Advertisement