How to write text to command prompt console windows?

I am using VC++ 6.0 to build a windows based application, however, my
application allows user to input command arguments in the dos prompt
windows. I want to have a warning message for user if they have input the
wrong arguments. How can I write text to the dos prompt windows if user
input the wrong arguments?

Thanks in advance.

Steven.


0
Steven
8/8/2006 11:07:57 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
581 Views

Similar Articles

[PageSpeed] 4

Steven wrote:
> I am using VC++ 6.0 to build a windows based application, however, my
> application allows user to input command arguments in the dos prompt
> windows. I want to have a warning message for user if they have input the
> wrong arguments. How can I write text to the dos prompt windows if user
> input the wrong arguments?
>
> Thanks in advance.
>
> Steven.

If your application is of the following form

                app.exe   argument1 argument2 argument3

then checking if user has entered proper number of arguments is easy.
In above example

if(argc !=4)          // 3 arguments and the app.exe
 {
           //WARNING Message Goes Here
}

If u want to check the integrity of each argument (if they are files)
then
use the argument to open the files If they dont open then give error.

0
pranavdes (41)
8/8/2006 12:13:15 PM
If your application is of the following form
                     
                app.exe   argument1 argument2 argument3

then checking if user has entered proper number of arguments is easy.
In above example 

if(argc !=4)          // 3 arguments and the app.exe
 {
           //WARNING Message Goes Here
}

If u want to check the integrity of each argument (if they are files) then 
use the argument to open the files If they dont open then give error.

"Steven" wrote:

> I am using VC++ 6.0 to build a windows based application, however, my
> application allows user to input command arguments in the dos prompt
> windows. I want to have a warning message for user if they have input the
> wrong arguments. How can I write text to the dos prompt windows if user
> input the wrong arguments?
> 
> Thanks in advance.
> 
> Steven.
> 
> 
> 
0
8/8/2006 12:27:42 PM
A serious question is why you would ever need to do this.  Since it is a Windows program,
having it "prompt" by some antiquated MS-DOS interaction method seems more than a little
bizarre, to understate the situation.  

I would suggest rethinking your application in terms of Windows and forget that MS-DOS
exists.  At the point where the program starts execution, the knowledge that it has been
launched from a command line is gone and there is no way to recover this information.
Furthermore, how would you handle this if the values were on the command line of a
shortcut that was double-clicked?  Bottom line: Window apps don't use consoles (at least
not without massive and usually inappropriate effort), and they can't interact with the
console from which they were launched.
				joe

On Tue, 8 Aug 2006 19:07:57 +0800, "Steven" <a@a.com> wrote:

>I am using VC++ 6.0 to build a windows based application, however, my
>application allows user to input command arguments in the dos prompt
>windows. I want to have a warning message for user if they have input the
>wrong arguments. How can I write text to the dos prompt windows if user
>input the wrong arguments?
>
>Thanks in advance.
>
>Steven.
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
8/8/2006 2:13:58 PM
The problem is that he wants to issue the warning message to the console window in which
that command was typed, and there is no way this is possible.

This is why MessageBox was invented.  Note also that argc is not defined for a Windows
app; it would be the global variable __argc and the arguments are found in __targv[i].

As far as the ability to open files, this belongs in the InitInstance handler of the app,
or perhaps even later, and at that point appropriate MessageBox calls can be issued if the
file is not valid.
				joe

On 8 Aug 2006 05:13:15 -0700, "nightcrawler" <pranavdes@gmail.com> wrote:

>
>Steven wrote:
>> I am using VC++ 6.0 to build a windows based application, however, my
>> application allows user to input command arguments in the dos prompt
>> windows. I want to have a warning message for user if they have input the
>> wrong arguments. How can I write text to the dos prompt windows if user
>> input the wrong arguments?
>>
>> Thanks in advance.
>>
>> Steven.
>
>If your application is of the following form
>
>                app.exe   argument1 argument2 argument3
>
>then checking if user has entered proper number of arguments is easy.
>In above example
>
>if(argc !=4)          // 3 arguments and the app.exe
> {
>           //WARNING Message Goes Here
>}
>
>If u want to check the integrity of each argument (if they are files)
>then
>use the argument to open the files If they dont open then give error.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
8/8/2006 2:19:14 PM
This might be useful for you:

http://www.codeproject.com/library/ConsoleFW.asp

Tom

"Steven" <a@a.com> wrote in message 
news:OGIZrrtuGHA.4460@TK2MSFTNGP04.phx.gbl...
>I am using VC++ 6.0 to build a windows based application, however, my
> application allows user to input command arguments in the dos prompt
> windows. I want to have a warning message for user if they have input the
> wrong arguments. How can I write text to the dos prompt windows if user
> input the wrong arguments?
>
> Thanks in advance.
>
> Steven.
>
> 


0
tserface (3861)
8/8/2006 3:38:50 PM
Reply:

Similar Artilces:

why it cann't work?(about subclass window)
void CXXXXTreeView::PreSubclassWindow() { // TODO: Add your specialized code here and/or call the base class CTreeView::PreSubclassWindow(); if(m_ctlDragTreeCtrl.GetSafeHwnd() ==NULL){ //VERIFY(m_ctlDragTreeCtrl.SubclassWindow(GetTreeCtrl().UnsubclassWindow())) ; //VERIFY(m_ctlDragTreeCtrl.SubclassWindow(GetTreeCtrl().GetSafeHwnd())); } } frist comment will cause assert in CTreeView::CreateEx(...) ,second comment direct cause assert,how i should subclass a treectrl in the treeview? "leighsword" <leighsword@163.net> wrote in message news:ubdD0bhZDHA.2136@TK2MSFTNGP...

Why don't pictures show in Publisher unless window is resized?
We use Publisher 2003. The pictures do not show unless we re-size the program window. Have any of you experienced this? How do you make the pictures appear without re-sizing the program window? Go to the manufacturer's web site of your graphics card and look around for an updated driver. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "gmstreet" <gmstreet@discussions.microsoft.com> wrote in message news:820D8893-26FF-4DEF-8D03-1AB26E7056B0@microsoft.com... > We use Publisher 2003. The pictures do not show unl...

Move Active Window
I need to write a program that moves the active window after every 20 seconds. I believe there must be some api function for that but dont know which one. Can any one help. In most case the active window will be VB6 IDE itself so if any active window is not easy is it easy to write a code that moves the VB6 IDE after every twenty seconds?? Don't ask why I want to do it, I just need to do it!! Thanks On Sat, 5 Dec 2009 18:05:15 +0500, "VB6Pro" <no_more_nonsense@myemail.com> wrote: >I need to write a program that moves the active window after every 20...

How to write a macro to modify an Excel chart
I want to "record" a macro that, for example, changes the line styles on an Excel chart. I tried by selecting the chart, then clicking on "record macro", manually changing the line style, and then clicking on "stop recording". But then when I tried to use the macro it wouldn't do anything. When I edited the macro there was no code, just the comment lines giving the shortcut. Is it possible to use the "record" feature for macros that work with charts, or must one start with the VB editor? Thanks, Henry -- leave well enough alone Hi, Here ...

Recordsets different with Windows Vista?
I have a new computer running Vista. I tried to use my database with it and have come across several problems. The one I'm working on now is a recordset. The following code creates links to documents related to my contacts. Public Sub Make_Link(docname As String, strComment As String, strDocType As String) 'Put a link to the file in the SubLinks form Dim rstLinks Set rstLinks = CurrentDb.OpenRecordset("Links") rstLinks.AddNew rstLinks.ContactID = Forms!Master!ContactID rstLinks.LinkDate = Now rstLinks.Link = "#" &...

How to delete text when it only appears in print review Publisher
I have a hidden x that can't be seen to delete it in publisher. It is visable in print review and prints out on paper How to find and remove it Maybe it is on the background. In Publisher 2000 and below, view, background, newer Publisher, view Master page. Do you have the picture detail selected? View, pictures, detailed display. Try selecting sections of the publication, it might become active. Is it a crop mark? If all fails, send the file to me, I'd like to see what is going on... Remove "my" to reply. -- Mary Sauer MS MVP http://office.microsoft.com/ http://msauer.mvp...

quoting selected text in e-mail reply
I have Outlook for Office XP, and I would like to be able to reply to e-mails by quoting selected areas of text from the original message. I can "quote" the entire message and delete certain parts, but I have not been able to select a certain part of the text and reply with just that part quoted. Thanks ...

How to Synchronize Combo Box with Text Box After Going to Next Rec
I have a combo box called [Title Pick] that I use to display catalog titles to get to the record for that title. I also have a text box, called Title, that shows the title I just selected in the combo box. In addition, I have several navigation buttons used to go to the next record, previous record, etc. After I navigate to a different record using one of these buttons, the text box, Title, has the correct value -- but the Combo Box, [Title Pick], still shows the value from the last time that combo box was used. How do I now get the combo box to show the correct title for that reco...

Function In A Text Box
Hi, I am trying to put a concatenate function in a text box. The error message is as follows: The text you have entered is not a valid reference or defined name. I want to concatenate some text with a number from the cell, A2. Any ideas would greatly appreciated. Regards Tubbsy -- tubbsy ------------------------------------------------------------------------ tubbsy's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24743 View this thread: http://www.excelforum.com/showthread.php?threadid=388332 Its not a perfect solution but you could perform the concat...

What is the correspondence to SqlDataSource in windows
Hello! The SqlDataSource Class is a part of System.Web Assembly and used by data-bound controls in ASP.NET Can somebody tell me what is the nearest correspondence to SqlDataSource in windows form //Tony "Tony Johansson" <johansson.andersson@telia.com> wrote in news:fTbWm.13647$U5.204106@newsb.telia.net: > The SqlDataSource Class is a part of System.Web Assembly and used by > data-bound controls in ASP.NET > > Can somebody tell me what is the nearest correspondence to > SqlDataSource in windows > form SqlDataSource is a wrapper ...

"News" missing from customize-commands-go
Good morning. The news Icon seems to have disappeared from customize commands. I am runing Outlook 2003 from a server at work , using MS Exchange. I was trying to set up news -- MS Newsgroups within Outlook as instructed by the Help proceedure, however, the News icon is no longer there. It was there at first. When I dragged it to my menu bar and attempted to sign into Newsgroups, it disappeared. I have never lost an icon from the commands before. I didn't think it was possible. Please advise See if this info helps: http://windowsitpro.com/article/articleid/43544/enable-outlook-200...

Error sending messages on Windows Mail
Have NOT been able to send emails from my Windows Mail account. Error message is as follows -- Unknown error has occurred - Server: smtpauth.earthlink.net Protocol: SMTP" Server response - '503STARTTLS command used when not advertised Port: 587 Secure (SSL): Yes Server Error #0x800CCC65 (this was for an outgoing message directed to a third party) I tried to send a message to my own email account and the Error Message was exactly the same, EXCEPT that the final line of the Error Message said - Server Error #0x800CCC90 I get error message numberox800ccc19 I wond...

Messenger no longer opens message window
When a Messenger contact is offline, I right click and select Send Email. In the past, a new message window would open for me to write the message. Outlook opens if it was closed, but the new message window doesn't; if Outlook was already opened, its icon in the system tray blinks, but a new message window does not open. I should point out that this started happening after I downloaded Mozilla Thunderbird, another mail program, and used it for a few days. I have since uninstalled it and returned to Outlook. I am having another, likely related problem. I have downloaded Mozilla Firefox br...

Window activation woes
Hi, I want to prevent multiple instances of my application running at the same time, which I've done, however when a second instance is started I want it to activate the main window of the first instance. This I have sort of done. When the second instance detects it isn't the first instance it uses BroadcastSystemMessage with a registered window message to tell the first instance to bring it's main window to the top. Below is the code I'm using for window activation: LRESULT CMainFrame::OnActivateInstance(WPARAM wParam, LPARAM lParam) { if (IsIconic()) ShowWindow(S...

Outlook (and Word) Spell check original text in reply
I have a couple of my users where Word spell checks original text i reply even though it is marked in tools as Do not Spell Check Origina Text in Reply. If I turn Word off as the editor, then it works fine. This does not occur on all of my machines, only on two... I use Word 2 and Outlook 2K. Any ideas why this is happening? I appreciate the help -- rcstechnologyPosted via http://www.officehelp.in - &lt;a href=&quot;http://www.officehelp.in&quot;&gt;Microsoft Office Software&lt;/a&gt it's because they have a prefix character set. http://www.outlook-tips.net/...

WLM, Windows Live Contacts, and Multiple Accounts
I have 2 Hotmail accounts configuring in WLM Desktop. When I select Go==>Contacts, the Windows Live Contacts dialog is shown, but only for _one_ of my email accounts. I can't figure out how to show the contacts related to the other account. Does anyone know how? Thanks, P. Upper right corner where your live acct ID is shown.. "sign in with a different ID". Choose other ID. "Oceanclub" <Oceanclub@discussions.microsoft.com> wrote in message news:95D4DAD4-3307-4FA7-8BE6-A73C4DE198D4@microsoft.com... > I have 2 Hotmail accounts configuring ...

Writing to a CStdioFile without a path?
Hello, I recently have encountered a problem with some code I have written involving writing to a file. I am writing to a text file which i open without specifying a path CStdioFile LogFile; LogFile.Open("log.xml", CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone | CFile::typeText); I then write to the file CString aString; aString.Format("<LOG>\n"); LogFile.WriteString(aString); This all seems to work fine. Of course the location of the fi...

text in downward arc?
Hi there, using publisher i want to create text in a downward arc. i have tried to use the upward arc in the word art section and invert that but the text flips. i want to be able to read it from left to right. No matter how i try the text will not read from left to right? what am i doing wrong? Word art will do that. Which version of Publisher are you using? -- JoAnn Paules MVP Microsoft [Publisher] ~~~~~ How to ask a question http://support.microsoft.com/KB/555375 "ian cobbledick" <ian cobbledick@discussions.microsoft.com> wrote in message news:64D9450C-7416-453...

Print excel file from DOS command line #2
It's possible to pass a parameter to VB ? (I never use VB) I need it becase I need to print different workbook with a .bat -- despistad ----------------------------------------------------------------------- despistado's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1629 View this thread: http://www.excelforum.com/showthread.php?threadid=27692 I create a PrintXLS.VBS file and put it in a safe spot. (I put it in "C:\my documents\scripting\printxls.vbs") This was in the file: Dim XL Dim XLWkbk Dim ObjArgs set objargs = wscr...

Help writing simpler macro?
Hello all, I have created a macro that makes some fields on a form visible and others not visible depending on the selection made from a dropdown list. Here is a portion of the current macro: Line 1: Condition= [Form]![Field1]="Caps" Action= SetValue Item= [Field2].[Visible] Expression= No Line 2: Condition= [Form]![Field1]="Caps" Action= SetValue Item= [Field3].[Visible] Expression= No Line 3: Condition= [Form]![Field1]="Caps" Action= SetValue Item= [Field4].[Visible] Expression= No So if "Caps" is chosen in Field1, then Field2, Field3, and Field4 a...

Two "versions" show up in window tab? file:1 file:2
I have a coworker who when he opens a file, and looks under the windo tab, two files of the same name show up separated by colon and number. e.g. file:1 and file:2 by switching from "version" 1 and 2, file is identical in both window and seems to be embedded in properties. He says he accidentaly hit some keys and it did this and I can't seem to be able to recreate this. Does anyone know what this function is? Thank -- mpoirier2 ----------------------------------------------------------------------- mpoirier23's Profile: http://www.excelforum.com/member.php?action=get...

search for text then return text
i need a fomula that will search down a specified cells in a column... look at the words in each cell and then display the text i want. for instance... I have a column with words in it and i want it to search through each cell/word for the letter "P"... then i want it to display a "P". if there are one or many instances where a "P" is in that column I want to only display "P". Maybe something like this... =IF(SUMPRODUCT(--(ISNUMBER(SEARCH("P",A1:A20)))),"P","") In this formula case is not a factor. P an...

How do I create a bulk mailing text box in Publisher?
-- Thomas -- Mike Thomas wrote: ...

Meeting requests appearing as text
Hi All, I've googled this problem a lot and not found anything useful. We have a client workstation running XP and Outlook 2003 that finds when they send meeting requests it just comes through as text, not a normal meeting request where you can click accept decline etc. I have sent test messages from his machine to myself (external) and I am also running XP with Outlook 2003. I have found a workaround - when setting up the meeting, go to actions -> forward as ical. But the user shouldnt have to do this should they. Any suggestions? Cheers Chris Hi have a look on this site: F...

Button text #3
I know I can change the text on a button with the following: GetDlgItem(IDC_BUTTON1)->SetWindowText("Enable"); What I would like to know, is it possible to get the text from a button? In other words if by clicking a button I change the text on the button to "Disable" but when clicked again it says "Enable". Can I check to see which it currently is? Thanks GetWindowText(...) but instead I would keep track of that with a boolean variable. m_Button1.SetWindowText(m_ShouldSayEnabled ? "Enable" : "Disable"); AliR. "Ed" <e...