| View previous topic :: View next topic |
| Author |
Message |
Lorrenzo Moderator
Reputation: 4
Joined: 02 Jun 2006 Posts: 3744
|
Posted: Thu Jun 07, 2007 6:32 pm Post subject: Delphi help |
|
|
Ok, so i'm a noob, just learning to use Delphi7... ...
So anyways, I was creating a simple program, similar to I believe breads..that just launchs programs..using ShellExecute.
I've got some of the programs to open such as Maple and the internet..but then when i try to get something like MSN Messenger, or LimeWire it won't work..I'm using
| Code: | | ShellExecute(Handle, 'open','C:\Program Files\LimeWire\LimeWire.exe', nil, nil, SW_SHOWNORMAL) ; |
I've also tried
| Code: | | ShellExecute(Handle, 'open','"C:\Program Files\LimeWire\LimeWire.exe"', nil, nil, SW_SHOWNORMAL) ; |
But no luck..
Can someone point me in the right direction?
_________________
LAWLrrenzolicious |
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Thu Jun 07, 2007 6:35 pm Post subject: |
|
|
Right direction == CreateProcess
ShellExecute is for opening something with what it's associated with... like a .txt file or a .html (or a .ct etc).
However, if you're starting up a .exe, you should be using CreateProcess.
Please don't let this lead to another one of those 'program opener YEAH!!!' releases
_________________
|
|
| Back to top |
|
 |
Lorrenzo Moderator
Reputation: 4
Joined: 02 Jun 2006 Posts: 3744
|
Posted: Thu Jun 07, 2007 6:36 pm Post subject: |
|
|
Ok, thank you..and don't worry..I would nvr release my peice of shit.
_________________
LAWLrrenzolicious |
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Thu Jun 07, 2007 6:40 pm Post subject: |
|
|
Whewt. Ahah
There are a few tricky things in it... just make sure to zeromemory() the two last parameters before you call it (the information parameters).
I don't want to post my code because you won't learn from switching out directories
_________________
|
|
| Back to top |
|
 |
Lorrenzo Moderator
Reputation: 4
Joined: 02 Jun 2006 Posts: 3744
|
Posted: Thu Jun 07, 2007 6:52 pm Post subject: |
|
|
Ok, Yeah..im a noob..and I learn veryyy slow..
So say i wanna run my LimeWire and I have this code..what would I do..
| Code: | {Supply a fully qualified path name in ProgramName}
procedure ExecNewProcess(ProgramName : String);
var
StartInfo : TStartupInfo;
ProcInfo : TProcessInformation;
CreateOK : Boolean;
begin
{ fill with known state }
FillChar(StartInfo,SizeOf(TStartupInfo),#0);
FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
CreateOK := CreateProcess(PChar(ProgramName),nil, nil, nil,False,
CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
nil, nil, StartInfo, ProcInfo);
{ check to see if successful }
if CreateOK then
//may or may not be needed. Usually wait for child processes
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end; |
_________________
LAWLrrenzolicious |
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Thu Jun 07, 2007 7:08 pm Post subject: |
|
|
Call the procedure in your button click section of the code by passing in the name of the program you would like to run.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
Lorrenzo Moderator
Reputation: 4
Joined: 02 Jun 2006 Posts: 3744
|
Posted: Thu Jun 07, 2007 7:19 pm Post subject: |
|
|
Um..yeah..does anyone know of any good really noob delphi tuts..
_________________
LAWLrrenzolicious |
|
| Back to top |
|
 |
|