Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


I want to GetCmdLine!

Posted on 1999-07-01
Medium Priority
Last Modified: 2010-08-05
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!
Question by:bert1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 1198891
MessageBox((const char*)TTestApp().cmdLine, "", MB_OK);

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

I need help!

Accepted Solution

KangaRoo earned 120 total points
ID: 1198892
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.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question