1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Rep Power

    Unhappy ShellExecuteA or ExtractFilePath(ParamStr(0)) fails in Win2000?

    Hi all!

    I wrote a small application in Delphi 4, that uses ShellExecuteA of Shell32.dll to launch another application.

    It works perfectly in Win 95, 98 and ME, but fails in Win2000. Error message reports that shell32.dll can not be found, though shell32.dll IS located at the System32 directory mentioned in the error message.

    Apparently ShellExecuteA doesn't work in Win2000 for some reason?

    Anyone any ideas? Other functions I could use?

    Here's how I have defined the function call:

    function ShellExecute(hWnd: HWND; Operation, FileName, Parameters, Directory: PChar; ShowCmd: Integer): HINST; stdcall;
    function ShellExecute; external 'shell32' name 'ShellExecuteA';
    Actual call:
    ShellExecute(handle, 'open', Pchar(ExePath) , nil, nil, SW_SHOWNORMAL);
    I derive a part of the ExePath path by ExtractFilePath(ParamStr(0)). Could it be that ExtractFilePath(ParamStr(0)) fails in Win2000?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Woodland Hills, Los Angeles County, California, USA
    Rep Power
    Sounds like you've come from a VB background. In the first place, a NT class system has ShellExecuteW since it is widechar capable. Also, why bother to prototype the exact call, when Delphi has a perfectly working version of the same.

    Actual call:
        ShellExecute(handle, 'open', ExePath , nil, nil, SW_SHOWNORMAL);
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo