Click here to Skip to main content
15,886,664 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: get the txt of wordArt with VBA Pin
CPallini5-Aug-12 21:03
mveCPallini5-Aug-12 21:03 
AnswerRe: get the txt of wordArt with VBA Pin
BCN-1635-Aug-12 21:17
BCN-1635-Aug-12 21:17 
QuestionMFC Ribbon Status Bar in VS2010 Pin
Rishav Prabhakar5-Aug-12 19:22
Rishav Prabhakar5-Aug-12 19:22 
QuestionCalling main from within Windows application Pin
PierreBokma5-Aug-12 3:34
PierreBokma5-Aug-12 3:34 
AnswerRe: Calling main from within Windows application Pin
Richard MacCutchan5-Aug-12 6:51
mveRichard MacCutchan5-Aug-12 6:51 
AnswerRe: Calling main from within Windows application Pin
jschell5-Aug-12 7:53
jschell5-Aug-12 7:53 
AnswerRe: Calling main from within Windows application Pin
pasztorpisti5-Aug-12 15:08
pasztorpisti5-Aug-12 15:08 
AnswerRe: Calling main from within Windows application Pin
Software_Developer5-Aug-12 18:37
Software_Developer5-Aug-12 18:37 
Try this.



C#
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
typedef TCHAR tchar;
typedef std::basic_string<tchar> tstring;
typedef std::basic_stringstream<tchar> tstringstream;
typedef std::vector<tstring> arg_vector;

bool filter(char c)
{
    return (c == '\"');
}

arg_vector cmdline_to_argv(tstring const & cmdline)
{
    arg_vector args;

    if (cmdline.empty())
        return args;

    bool together = false;
    bool only_spaces = true;
    tstring::size_type laststart = 0;

    for (tstring::size_type n = 0; n < cmdline.length(); ++n)
    {
        if (cmdline[n] == '\"')
        {
            together = !together;
        }

        bool space = !!isspace(cmdline[n]);

        if (space && !together)
        {
            if (!only_spaces)
            {
                tstring arg = cmdline.substr(laststart, n - laststart + 1);
                arg.resize(std::remove_if(arg.begin(), arg.end(), &filter) - arg.begin());
                args.push_back(arg);
            }
            laststart = n + 1;
        }

        if (space)
            only_spaces = true;
        else
            only_spaces = false;
    }

    if (!only_spaces)
    {
        tstring arg = cmdline.substr(laststart, cmdline.length() - laststart + 1);
        arg.resize(std::remove_if(arg.begin(), arg.end(), &filter) - arg.begin());
        args.push_back(arg);
    }

    return args;
}


int main(arg_vector const & args)
{
    tstringstream strm;
    strm << args.size() << " arguments!\n";
    for (arg_vector::size_type n = 0; n < args.size(); ++n)
        strm << "Argument #" << (n + 1) << ": " << args[n] << "\n";
    MessageBox(NULL, strm.str().c_str(), TEXT("Command Line Test"), MB_OK | MB_ICONINFORMATION);
    return 0;
}

int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int show)
{
    return main(cmdline_to_argv(GetCommandLine()));
}

QuestionBEX runtime error! Pin
Le@rner2-Aug-12 18:54
Le@rner2-Aug-12 18:54 
AnswerRe: BEX runtime error! Pin
Peter_in_27802-Aug-12 19:04
professionalPeter_in_27802-Aug-12 19:04 
AnswerRe: BEX runtime error! Pin
Richard MacCutchan2-Aug-12 21:21
mveRichard MacCutchan2-Aug-12 21:21 
AnswerRe: BEX runtime error! Pin
enhzflep2-Aug-12 23:41
enhzflep2-Aug-12 23:41 
AnswerRe: BEX runtime error! Pin
Software_Developer3-Aug-12 0:34
Software_Developer3-Aug-12 0:34 
AnswerRe: BEX runtime error! Pin
Wes Aday3-Aug-12 6:54
professionalWes Aday3-Aug-12 6:54 
Questioncalling a user32.lib method in c++ application gives Linker error Pin
Virendra_ec102-Aug-12 2:31
Virendra_ec102-Aug-12 2:31 
AnswerRe: calling a user32.lib method in c++ application gives Linker error Pin
Mass Nerder2-Aug-12 3:27
Mass Nerder2-Aug-12 3:27 
Questionwait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
Virendra_ec102-Aug-12 2:23
Virendra_ec102-Aug-12 2:23 
AnswerRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
pasztorpisti2-Aug-12 3:58
pasztorpisti2-Aug-12 3:58 
AnswerRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
_AnsHUMAN_ 2-Aug-12 3:59
_AnsHUMAN_ 2-Aug-12 3:59 
GeneralRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
Stephen Hewitt3-Aug-12 6:34
Stephen Hewitt3-Aug-12 6:34 
GeneralRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
Virendra_ec1012-Aug-12 20:37
Virendra_ec1012-Aug-12 20:37 
QuestionRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
David Crow2-Aug-12 6:55
David Crow2-Aug-12 6:55 
AnswerRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
Virendra_ec1012-Aug-12 20:39
Virendra_ec1012-Aug-12 20:39 
AnswerRe: wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7 Pin
Stephen Hewitt3-Aug-12 6:36
Stephen Hewitt3-Aug-12 6:36 
QuestionTab control Pin
ekinnh1-Aug-12 15:38
ekinnh1-Aug-12 15:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.