Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Command line arguments

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Command line arguments
#3444
Posted by: 2004-03-03 13:44:04
I have been unsuccessful in using the argc and argv variables in my app.  Where exactly can you use the argc and argv varilables in a windows app?
That problem, however is not my biggest problem.  My biggest problem is figuring out how to be able to allow the user to right-click their file and "Kount" the number of words in it.  How do I get my program to know what file was right-clicked and opened?


Any help at all is GREATLY appreciated!

Thanks!
Message2. Re: Command line arguments
#3445
Posted by: upCASE 2004-03-03 16:29:07
Hi!
Well, argc and argv are used in windows apps just like they're used in every C/C++/Java app. In your main()/WinMain() function you can use them, where argc is the count of arguments and argv is a pointer pointer (or array of pointers) to strings, where the first element of the array is always the name of you app. So
myapp.exe hello world
gives
argv[0] = "myapp.exe"
argv[1] = "hellp"
argv[2] = "world"

What you do with these is totaly up to you. On Windows you normaly pass them by using the console, a link or via the "open" command of the explorer.
To your second problem I guess argv is the solution. When a user clicks a file in the explorer you could specify an open command that takes the filename as the first command line argument, opens it and counts the words.

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2022-12-9  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0