Command-line argument syntax
I'm using Visual C++.NET. I need to pass a port number to my gui. What the syntax for passing arguments to "int __stdcall WinMain()." For regular C++ it would be "int main(int argc, char* argv[])" Thanks.
DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
I get a compiler error :
error C2065 : 'HINSTANCE': undeclared identifier
DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
Below is a simple example I found on MSDN. I added the #include but it still has an error. Am I forgetting to set something in my environment? I'm using Visual C++.NET 2003.
error C2731: 'WinMain' : function cannot be overloaded
#include
#using
#using
#using
#undef MessageBox // undefine the MessageBox macro of windows.h to use the managed MessageBox class
void __stdcall WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
long lpCmdLine,
int nCmdShow)
{
System::Windows::Forms::MessageBox::Show("Hello, Windows Forms");
}
DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
I added stdafx.h/.cpp and now it's working. But, how do you detect that no arguments were passed in? I want to set a default value when arguments are not provided.
DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0