Well I was looking for a way to detect command lines
and files opened with my application
Just a simple way if possible
or a header that does it easly
something like: string s = GetCommandLine() xD (kidding)
Well I was looking for a way to detect command lines
and files opened with my application
Just a simple way if possible
or a header that does it easly
something like: string s = GetCommandLine() xD (kidding)
Last edited by Need_O2; 04-16-2008 at 01:10 PM.
your application does not know what it is doing?Well I was looking for a way to detect command lines
and files opened with my application
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
I open it with a file for example you know
Like opening paint files with mspaint
I want to detect what I opened it with
Did I miss the no beginners allowed sign ?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Start -> Run -> $My application path$ $File to open with Path$
so I opened the "File to open with" with my application
So I want to store $File to open with Path$ in a string to know what I opened with it
like
mspaint "C:\Pictures\Lieandsorrow.jpeg"
lieandsorrow.jpeg gets opened with mspaint
mspaint knows about "C:\Pictures\Lieandsorrow.jpeg" and it opens it
I want the "knows about" part
I'm also confused about what you want to do: Are you asking "how do I get the command line arguments", or something else? The former is described in the FAQ section in the blue line above this thread.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I think the OP is trying to open a file from Windows Explorer, for example, and then determine which program was launched to open the file.
The only way I can think of to do this is to get the command-line string that was used to execute every running program, and search through those for the filename in question. I'm not sure how to do this, or if it's even possible.
[edit] Didn't see the last two posts. It's what happens with tabs.
I think matsp might be right. Here's the FAQ. http://faq.cprogramming.com/cgi-bin/...&id=1043284392
[/edit]
Last edited by dwks; 04-16-2008 at 01:27 PM.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I'm confused as well but as matsp suggests it seems that you what you are looking for are command line arguments.
you mean "Run a program from within a program"
hmm didnt see FAQs before
They seem much usefull
Thanks !!!
You might also want to read the FAQ I posted in my edit. http://faq.cprogramming.com/cgi-bin/...&id=1043284392
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I simply wanted make me able to right click a file and say open with <My app name>
since I know some about editing class options from registry. making app open the file opened it with was last thing to do
(LoL I don't know how to edit registry with c ...)
Really how to edit registry ?
is there a simple way like game maker ? (at least Im sure it would be possible with a header)
it was like
SetRegistryRoot(0) // like (not exactly): 0 = local machine,1 = classes root
RegistryWriteStringEx("path","variable","string") // creates all if doesnt exist (no path = creates path, no variable = creates variable)
And how to copy a file xD ?
Last edited by Need_O2; 04-16-2008 at 01:48 PM.
I see what you're wanting to do, and I am not sure how to do it now that I think about it.
For those who may know heres a rewording of what is trying to be done:
Think about when you double click a JPG file. Windows automatically opens up the right program and that program knows which file you opened. The OP wants to know how to make his program work like that. So if a text editor is made and you double click a TXT file, your custom program will open that file. The problem is, how does your program know what file you double clicked.
[edit]
The more I think about it, there must be something similar to the standard "command line arguments".
[/edit]
Last edited by Vicious; 04-16-2008 at 02:09 PM.
What is C++?
It parses main argv array or WinMain lpCmdLine parameterThe problem is, how does your program know what file you double clicked.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
That makes sence. So one would simply check for the existance of the arguments and parse out a file name to open.
What is C++?
Probably, if there is more than one command line argument, the second argument is assumed to be the file to open. So when the program starts, you check the number of command line arguments, and try to load the file if it is specified.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.