473,671 Members | 2,426 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 2266
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
6653
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
3309
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
4878
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
22032
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
2749
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
7685
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
1349
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
10503
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
9357
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
8481
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
8400
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,...
1
8602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8672
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...
1
6234
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.