Guidance Forums / wxWidgets (wxWindows) in C++ / Command line arguments

Search 搜索
Home Home

Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Command line arguments
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!

Message2. Re: Command line arguments
Posted by: upCASE 2004-03-03 16:29:07
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
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.

If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
© Fri 2024-6-14  Guidance Laboratory Inc. Hits:0