Link to home
Start Free TrialLog in
Avatar of zstafa
zstafa

asked on

What do I put in ParseParam?

I'm trying to convert my MFC to accept command line args so I do this,

CCommandLineInfo cmdInfo;
ParseCommandLine( cmdInfo );
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

now I'm having trouble figuring out how to do the last line
cmdArg = cmdInfo.ParseParam(???????);

I want to read in a string, an integer, and a couple of LONGINTS.

Thanks
Avatar of jkr
jkr
Flag of Germany image

There's a nice Article on CodeProject that illustrates how to do that: http://www.codeproject.com/library/PlgInArchSingInst.asp ("MFC extension library : Single instance Plug-In"), in particular http://www.codeproject.com/library/PlgInArchSingInst.asp#process ("Processing the new command line")

void CSIPlugIn::ParseNewCommandLine(CCommandLineInfo& rCmdInfo)
{
    for (int i = 0; i < m_commandLineParameters.size(); i++)
    {
        BOOL bFlag = FALSE;
        BOOL bLast = ((i + 1) == m_commandLineParameters.size());
        if (m_commandLineParameters[i].GetAt(0) == '-'
             || m_commandLineParameters[i].GetAt(0) == '/')
        {
            m_commandLineParameters[i] =
m_commandLineParameters[i].Right(m_commandLineParameters[i].GetLength() - 1);
            // remove flag specifier
            bFlag = TRUE;
        }
        rCmdInfo.ParseParam(m_commandLineParameters[i], bFlag, bLast);
    }
}

Avatar of zstafa
zstafa

ASKER

jkr that is for a new command line instance correct? I just need to do this once at the beginning. Thanks
>>I just need to do this once at the beginning

Yes, but the principle remains the same, regardless of when you do that.
Avatar of zstafa

ASKER

Is there any way to do this with the current direction I am going or do I have to use this plugin?
You should just use the part of the plugin's code that does the parameter parsing - no need to use the whole thing.
Avatar of zstafa

ASKER

In your above class where did you get the CSIPlugIn from? Could you give a little more detail please. Thanks
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial