|
i'm in the process of writing a program that i want only to be able to run with the correct command line parameters.
basicly i want the program only go run when it is called by another program.
i'm using the win32 api and opengl, i know that lpCmdLine accepts the command line parameters but i cant figure out how to set the parameters.
|
|
|
|
|
Feralrath wrote: but i cant figure out how to set the parameters
What do you mean by that ? They are simply passed when your program is executed. If you double-click on your program in explorer, they will be empty. If you start your program through the console, you can provide arguments by typing them after the name of your program.
|
|
|
|
|
How Cedric Moonen says, in Command Line you can start your application with parameters like this
c:\>myprog param1 param2 param3 --> Where "myprog" is your application's Executable file
You can add more than 3 parameters
In Windows-Mode you can set the parameters like this :
http://developer.valvesoftware.com/w/images/6/63/Game_shortcut.jpg[^]
the "-game" is for example a parameter
|
|
|
|
|
Feralrath wrote: i cant figure out how to set the parameters.
I get the impression that you want to start your application from another application that you've written as well.
You should use ::ShellExecute() for that, or ::CreateProcess() . Both of these functions have a formal parameter where you should provide the desired command line arguments for the newly launched application.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
i guess i should have been a little more clear(5:30am). i know how to launche the program with parameters.
my question is how do i set the parameters in the program
i.e.
if(lpCmdLine != 12345)
{
return 0;
}
how can i set the variable for lpCmdLine to accept
|
|
|
|
|
Feralrath wrote: i guess i should have been a little more clear(5:30am)
Well, perhaps you should get some sleep because you're still not very clear...;)
Feralrath wrote: my question is how do i set the parameters in the program
How can you ask this question if you say that you know how to launch the program with parameters?
Is this question about the program that is supposed to be started, or about the program that starts the other program?
Feralrath wrote: how can i set the variable for lpCmdLine to accept
I interpret lpCmdLine as the string containing the command line arguments in your program that is supposed to be started. You don't assign anything to this string, you should parse it to extract the arguments from it.
If this is about how to compose the string containing the command line arguments in the program that starts the other, you can use ::sprintf() for that.
See here[^] for info about how to use ::sprintf() .
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
the question is about the application being lauched, how to i set it so that i will not launch when double clicked only when the correct command like argument is given?
|
|
|
|
|
|
You can't prevent the program being launched. In the program being launched, validate the command line parameters. If they aren't correct, simply exit immediately.
Software Zen: delete this;
|
|
|
|
|
Gary summarizes it quite well: you cannot prevent the application from being launched.
Think about it this way:
You have put the logic that determines whether the application is allowed to run or not inside the application itself. How could that piece of code make any decision without being executed?
Perhaps this is not really what you want, but then you might consider the design of your solution and where to put the logic that allows the application to start.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
If you're still hung up on accessing the command line, use argc and argv (or if it's a GUI app, __argc and __argv )
|
|
|
|
|
thank you all for tying to help, but was just haveing a brain meltdown last night.
bool run = FALSE;
if(strcmp(lpCmdLine, "string")==0)
run = TRUE
if(!run)
{
return 0;
}
i guess it i just couldn't see what was stairing me in the face.
|
|
|
|
|
Let say if I have one combox, I want to change its propety using comparation.
BOOL CASE1;
if (CASE1==TRUE)
XXXXX; //ComboBox change to Comboedit box
How can I write the code to change its properties?
|
|
|
|
|
feiutm9898 wrote: How can I write the code to change its properties?
Use ModifyStyle .
|
|
|
|
|
You can use for example of ModifyStyle(0,CBS_AUTOHSCROLL);
|
|
|
|
|
Hi All
I have made one console application in VC++.Now i want to add different colors for stdout and stdin.
I have used the following code.
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hStdOut , &ConsoleScreenBufferInfoOutPut);
//Setting color for stdout
ConsoleScreenBufferInfoOutPut.wAttributes = FOREGROUND_GREEN;
FillConsoleOutputAttribute(hStdOut , ConsoleScreenBufferInfoOutPut.wAttributes , ConsoleScreenBufferInfoOutPut.dwSize.X*ConsoleScreenBufferInfoOutPut.dwSize.Y,
origin,&dwrite );
SetConsoleTextAttribute(hStdOut ,ConsoleScreenBufferInfoOutPut.wAttributes);
//Setting color for stderr
hStdErr = GetStdHandle(STD_ERROR_HANDLE);
GetConsoleScreenBufferInfo(hStdErr , &ConsoleScreenBufferInfo);
ConsoleScreenBufferInfo.wAttributes = FOREGROUND_RED;
FillConsoleOutputAttribute(hStdErr , ConsoleScreenBufferInfo.wAttributes , ConsoleScreenBufferInfo.dwSize.X*ConsoleScreenBufferInfo.dwSize.Y,
origin,&dwrite );
Using this code I am getting the color for stdout as red.
But I have chosen green color for stdout.
Can anybody help me in this regard?
SetConsoleTextAttribute(hStdErr ,ConsoleScreenBufferInfo.wAttributes);
|
|
|
|
|
|
Thanks for your reply.
But I want to use win32 API and does not want to include console.h
Can it be done with the code that I have mentioned.
|
|
|
|
|
i am developing an application in vc++ that can get complete system information hardware and software both..now i want to fatch all system files information in vc++.But i don't have any clue.Can anyone help me??
Any help would be appreciated.
thanking you.
|
|
|
|
|
|
tyjjrtruy4teqye7nyue7qay wrote: ...i want to fatch all system files information in vc++.
This is a very broad request. Can you be a bit more specific?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hello David,
Sorry for late reply, i actually want to get names,extention,creation date,last accessed
date,path of the file etc. about all system related files.these file can be os related.
waiting for reply.
thanking you.
|
|
|
|
|
vankadia_n wrote: ...system related files...
Which are?
To get information for any file, just use GetFileAttributes() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
hello,
Sorry for late reply, i actually want to get names,extention,creation date,last accessed date,path of the file etc. about all system related files.these file can be os related.these files can be dlls,exe,or any else files.
waiting for reply.
thanking you.
|
|
|
|