473,770 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Aug 8 '06 #1
3 2277
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?
When your app starts, validate the arguments in the argument list (called
argv typically)
If the arguments are OK, proceed with your app. If they aren't, print an
appropriate message to the console, with printf, fprints, or cout.

--
Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"

Aug 8 '06 #2
Bruno van Dooren [MVP VC++] 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?

When your app starts, validate the arguments in the argument list (called
argv typically)
If the arguments are OK, proceed with your app. If they aren't, print an
appropriate message to the console, with printf, fprints, or cout.
OTOH, if they start the application with an icon (and there isn't a DOS command
window) you have to reflect the error in a messagebox anyway so why not just do
it that way for both cases?

/steveA

--
Steve Alpert
my email fgrir.nycreg @ tr.pbz is encrypted with ROT13 (www.rot13.org) and spaces

Aug 8 '06 #3
Use AllocConsole() to attach the stdin, stdout, stderr handles so that
printf(), fprintf(stderr, ...) etc. will show up for gui apps.
"Steven" <a@a.comwrote in message
news:uW******** ******@TK2MSFTN GP04.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.


Aug 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6661
by: Eric Ching | last post by:
Can I run pythonw with a script that takes command line arguments then launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and nothing happens. Nothing, as in I am immediately returned to the DOS prompt. I just started learning Python a couple of weeks ago, so please bear with me. I have a script that(for now) uses command line arguments then launches a window (Tk). Once I have entered the arguments and the window is...
15
3336
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
18
4893
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
2
22036
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by using the Console.Write command. The question is how can I see the outputs in the client machine ? Is there a specific programm to do it or Can I use the prompt window ?
3
2756
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from this app: =============================== static void Main(string args) { if (args.Length > 0) Console.SetIn(new StreamReader(args)); //executes if I don't use the "<", ">" redirection syntax when invoking XmlTextReader xmlin = new...
1
7689
by: Zhou Jingxiong | last post by:
Hi I am using third party COM component which come with an installation program (.exe file included). The program will be register to registry automatically upon installation. There is no problem calling the COM component from VB.net Module from DOS Command Prompt : Imports System
3
1353
by: TBoon | last post by:
Hi there, A console application (.exe) can be executed at Command Prompt or Windows (double-click). Is there a way to detect whether if it is executed at CP or Windows? regards, Boon
4
10514
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it doesn't seem to write to the screen in the way I would expect. The output is:
7
9372
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should display the Windows form. The form is being displayed but the command only returns when the form is closed. I want the command line to return immediately, leaving the form displayed.
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.