Archived

This topic is now archived and is closed to further replies.

mdias

"WinMain()" as "_tWinMain()"

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
_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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites