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)
Printable View
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)
your application does not know what it is doing?Quote:
Well I was looking for a way to detect command lines
and files opened with my application
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 ?
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
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]
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
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 ?
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]
It parses main argv array or WinMain lpCmdLine parameterQuote:
The problem is, how does your program know what file you double clicked.
That makes sence. So one would simply check for the existance of the arguments and parse out a file name to open.
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.