Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send a variable from WinMain to form 1

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
Hallo.
I need to be able to read the command line variable from WinMain in my main form, but I have no idea of how to do this.
I have tried creating a global variable to hold it, but to no avail.
Obviously, I need to do something before the Application->Run() command, but I am drawing a blank.
Can anyone help?
Douglas JL.

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
Easy!

_argv[] is pointers to the arguments given.

_argv[0] is the program itself with path, i.e. if you call a program "C:\Testlib\Testprog.exe" with the parameters "Test" 1 2 3 (quotes just for clarity) it would give:
_argv[0] points on the string: "C:\Testlib\Testprog.exe"
_argv[1] points on the string: "Test"
_argv[2] points on the string: "1"
and so forth. Quotes is just to illustrate, it's really zero-terminated strings.

The number of arguments is in _argc.

Totte
 
Brilliant!
Thanks alot, Totte!
DJL

A salesman is a machine for turning coke into obnoxious arrogance.

Common sense is what tells you the world is flat.

 
Nemas problemas.

By the way, as i recall it _argc is always at least 1 whick corrospond to the _argv[0] i.e. the program itself so to speak.

Totte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top