Sign in to follow this  
beebs1

Unicode WinMain()

Recommended Posts

Hiya, I believe there is a C++ function which can be used in place of WinMain, which accepts a wide character command-line argument, but I can't seem to find anything about it. Can anyone tell me what the function declaration is? I think I've seen it before as int APIENTRY tWinMain( /*something something*/ );, but I could be wrong. Thanks for any help :) James.

Share this post


Link to post
Share on other sites
From MSDN:

[...]
This means that WinMain cannot be used by Unicode programs. The GetCommandLineW function can be used to obtain the command line as a Unicode string. Some programming frameworks might provide an alternative entry point that provides a Unicode command line. For example, the Microsoft Visual Studio C++ complier uses the name wWinMain for the Unicode entry point.

With that in mind, what about this?

Share this post


Link to post
Share on other sites
Thanks, that's exactly what I was looking for. Rating++ [smile]

If I can change the topic slightly, I've been trying to write a simple algorithm to read in record structures from a file, but I've come across a problem. I open the file using std::ifstream, and then use this:


std::ifstream in( L"test.txt", std::ios::in | std::ios::binary );
if( !in.is_open() ) return false;

// read in the file record by record
while( !in.eof() )
{
// read in various values...
}


Because the EOF flag is only set when you try to read past the end of the file, it always tries to read one record too many. Can anyone suggest a way of correcting this?

Thanks again.

Share this post


Link to post
Share on other sites

std::ifstream in( L"test.txt", std::ios::in | std::ios::binary );
if( !in.is_open() ) return false;

// read in the file record by record
while( !in.eof() )
{
// Try to read -- EOF set if past the end of the file

if (!in.eof)
// read in various values...
}


It's not the tidiest, but as far as I know it's the only way to do it (although another alternative, which is probably better, would be to use the same technique but extract it to some sort of 'getSize' function, and then loop until you reach that size).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this