I want to GetCmdLine!

How do I write the code to get the command line when I run an .exe file?
I have tried with GetCmdLine procedure but I cant get it to work. Here is the code:
class TTestApp : public TApplication {
         static string& cmdLine;
    TTestApp() : TApplication() {}
    void InitMainWindow();
string& TTestApp::cmdLine = GetCmdLine();
MessageBox(cmdLine, "", MB_OK);

I want to print the cmdLine in a MessageBox!
Who is Participating?
KangaRooConnect With a Mentor Commented:
string& TTestApp::cmdLine = GetCmdLine();
MessageBox(cmdLine.c_str(), "", MB_OK);

You cannot simply convert a string object to a char*, you need strings member function c_str() to return a C-style char* string.
bert1Author Commented:
MessageBox((const char*)TTestApp().cmdLine, "", MB_OK);

This dont give me the right string ... I got like X*y

I need help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.