Get games to start with Visual Basic C++

Started by
7 comments, last by pc_verden 22 years, 8 months ago
I am trying to make my own little program that will start everything on my desktop within the program. I can get the normal programs like Word, Execl and Netscape to work by using the easy WinExec code, but this doesn''t work for games. Do anyone know how to make them work. I would love to get som help with this because it is really annoying. I been looking all over the Internet and haven''t found anything. PLEASE HELP. Thank you if you can help.
Advertisement
You can always try ShellExecute. Remember, though, that the programs you can''t launch may be wanting some type of command line switch, check the short cuts you normally use to launch them, and see if there''re any swiches.

[Resist Windows XP''s Invasive Production Activation Technology!]
I am sorry I forgot to tell you that i am a beginner so I didn''t really get what you mean''t by ShellExecute. can you show me an example. Would love if you do.
Thank for bothering to help me.
There''s a function called ShellExecute, it''s just like WinExec
but more flexible, look it up in the MSDN documents.
I''m sorry, but i still can''t get what you what me to do.
I looked in the MSDN under Shell, but i don''t know which
one to use. I know I might be making it difficult for you but
I just don''t know any better.
Thanks again.
HINSTANCE ShellExecute(    HWND hwnd,     LPCTSTR lpOperation,    LPCTSTR lpFile,     LPCTSTR lpParameters,     LPCTSTR lpDirectory,    INT nShowCmd);	

Now, the first variable (hwnd) is the parent window. Either make it your Window or NULL.

The second (lpOperation) should normally be "open" (with the quotes).

The third is the file (the program) you want to run. I would be something like "abc.exe".

The fourth are any parameters that the program needs. Normally this can simply be "".

The fifth is the directory of the file that you specified. I would be something like "C:\\Something" (remember that ''\\'' becomes ''\'' when compiled).

The sixth is how to show the program, normally it''d just be SW_SHOWDEFAULT.

[Resist Windows XP''s Invasive Production Activation Technology!]
I have put in this into the program:
void CProgrammerDlg::OnUnrealtouBtn()
{
// TODO: Add your control notification handler code here

HINSTANCE ShellExecute(
HWND Window,
LPCTSTR lp"open",
LPCTSTR lp"Unrealtournament.exe",
LPCTSTR lp"",
LPCTSTR lp"D:\\UnrealTournament\\System",
INT nSW_SHOWDEFAULT
);

}
THis is for Unreal Tournament and it comes up with the error
Missing '','' before ''string'' and ''string''
both shows up in lp"open" part.
otherwise it doesn''t come up with any more errors

What should I do?
You really should learn C++ bfore you start doing this... But if you read the function definition the first word is the variable type (HWND is handle to a window, LPCSTR is constant string, etc), think of them the same way you think of int. So if you make a function like this:

void DoSomething(int something)

When you call it you don't type this:

void DoSomething(int 5);

You type this:

DoSomething(5);

Same thing with ShellExecute. Try this instead of what you have:

void CProgrammerDlg::OnUnrealtouBtn()
{

ShellExecute(NULL,"open",
"UnrealTournament.exe",
"",
"D:\\UnrealTournament.exe\\System\\",
SW_SHOWDEFAULT
);

}




Edited by - impossible on August 6, 2001 12:59:41 PM
Thank all of you for your help.
I finally got it to work.
I can finally finish my project.
Now I can go et finish with it so I can begin my Operation Flashpoint Mod.
Thanks.

This topic is closed to new replies.

Advertisement