-
February 11th, 2013, 04:33 AM
#1
How to read sentence from Command line with MFC?
I want to read sentence from command line. I open some program which run in command line and I have to wait for that program process. So , I don't know when process success .I can't type next command if can't read sentence from command. I use
Code:
wprintf(GetCommandLine());
but it show
"C:\Users\PKRU\documents\visual studio 2010\Projects\Virus Scan\Debug\MyProgram
please help me How to read sentence from Command line with MFC ?
-
February 11th, 2013, 04:54 AM
#2
Re: How to read sentence from Command line with MFC?
There is a MFC class CCommandineInfo
You may also want to look at this thread
Victor Nijegorodov
-
February 11th, 2013, 11:13 AM
#3
Re: How to read sentence from Command line with MFC?
Code:
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
int _tmain()
{
_tprintf(GetCommandLine());
return 0;
}
Code:
D:\Temp\80>cl 80.cpp /D"UNICODE" /D"_UNICODE"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
80.cpp
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:80.exe
80.obj
D:\Temp\80>80.exe iuhbiub oiono
D:\Temp\80\80.exe iuhbiub oiono
Best regards,
Igor
-
February 11th, 2013, 12:42 PM
#4
Re: How to read sentence from Command line with MFC?
Thank you for answer. I use this code in VC
int _tmain()
{
system("D:");
_tprintf(GetCommandLine());
getch();
return 0;
}
but when I click run button it show "C:\Users\MAX\Documents\Visual Studio 2010\Projects\TestCmd\Debug\TestCmd.exe"
I read CCommandineInfo the function ParseCommandLine can send parameter from command to MFC, But I want to know when my console process success and ask for send Y/N to command. If MFC can know when it ask Y/N ,then I can send char to process next command.
-
February 11th, 2013, 12:46 PM
#5
Re: How to read sentence from Command line with MFC?
Originally Posted by mmc01
... when I click run button it show "C:\Users\MAX\Documents\Visual Studio 2010\Projects\TestCmd\Debug\TestCmd.exe"
And what command line parameters (exactly!) did you pass in?
Victor Nijegorodov
-
February 11th, 2013, 01:07 PM
#6
Re: How to read sentence from Command line with MFC?
Originally Posted by mmc01
but when I click run button it show "C:\Users\MAX\Documents\Visual Studio 2010\Projects\TestCmd\Debug\TestCmd.exe"
And what did you expect? This is exactly the command line your process has been run with. Do you have any idea what command line is? I wonder what sense that system("D:"); makes for you?
I read CCommandineInfo the function ParseCommandLine can send parameter from command to MFC, But I want to know when my console process success and ask for send Y/N to command. If MFC can know when it ask Y/N ,then I can send char to process next command.
You're trying to do something you have no idea about. You cannot program Windows without knowing how the very basic OS mechanisms work.
When program exits it always provides exit code specific to the circumstances of termination. By the code value any outer process can tell if the exit was successful or not, and typically 0 means success (a UNIX/POSIX legacy). But the part about MFC knowing something and sending another something sounds totally gibberish. This is what you have to explain, if you want to be really helped.
Last edited by Igor Vartanov; February 11th, 2013 at 01:17 PM.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|