Delphi help needed

Posted by anze89 
Delphi help needed
Date: November 12, 2006 01:44PM
Posted by: anze89
I want to create a program with buttons that would start another application (in my case my games and programs). I use this line in delphi:

ShellExecute(self.WindowHandle,'open',PChar('D:\Games\Simbin\GTR2\GTR2.exe';),nil,nil, SW_SHOWNORMAL);

But it only works on some games (it doesn't work on GTR2, LFS2, NFS U2, NFS MW, NFS Carbon...)

Where's the problem?










Edited 1 time(s). Last edit at 11/12/2006 01:44PM by anze89.
Re: Delphi help needed
Date: November 12, 2006 09:07PM
Posted by: anze89
anyone? :s






Re: Delphi help needed
Date: November 13, 2006 02:05AM
Posted by: ZaZ
I think there's no real need to cast the filename to PChar as Delphi should do that for you.
You're also being inconsistent as LPCTSTR lpOperation (2nd parameter) is also a PChar in Delphi.
Anyway, my first bet would be the working directory of the apps you're trying to launch.

ShellExecute(0,'open','D:\Games\Simbin\GTR2\GTR2.exe',nil,'D:\Games\Simbin\GTR2\', SW_SHOWNORMAL);

Grab the Shellexecute return code in an int and check if it is other than 32.
If it is, then look up the error number or compare it to

ERROR_FILE_NOT_FOUND
ERROR_PATH_NOT_FOUND
ERROR_BAD_FORMAT
SE_ERR_ACCESSDENIED
SE_ERR_ASSOCINCOMPLETE
SE_ERR_DDEBUSY
SE_ERR_DDEFAIL
SE_ERR_DDETIMEOUT
SE_ERR_DLLNOTFOUND
SE_ERR_FNF
SE_ERR_NOASSOC
SE_ERR_OOM
SE_ERR_PNF
SE_ERR_SHARE

To see why it is failing





I'd rather have a bottle in front of me than a frontal lobotomy




Edited 1 time(s). Last edit at 11/13/2006 02:06AM by ZaZ.
Re: Delphi help needed
Date: November 13, 2006 01:54PM
Posted by: anze89
thanks for the help ZaZ! The program now works!






Re: Delphi help needed
Date: November 16, 2006 10:54AM
Posted by: Bernie The Bolt
I realise that you may just be doing this for the fun of it. But you know there's a handy little bit of Windows that does just what you're wanting?

It looks a bit like this:
Re: Delphi help needed
Date: November 16, 2006 02:20PM
Posted by: anze89
is that vista or just a vista theme? In any case it looks nice, but it becomes useless IMO when you have around 60 games and programs. I'm now trying to figure it out how could I minimalize my program to tray bar, so that I could quickly start the application that I want (through my program).






Sorry, only registered users may post in this forum.

Click here to login

Maintainer: mortal, stephan | Design: stephan, Lo2k | Moderatoren: mortal, TomMK, Noog, stephan | Downloads: Lo2k | Supported by: Atlassian Experts Berlin | Forum Rules | Policy