November 24th, 2004, 06:22 AM
ShellExecuteA or ExtractFilePath(ParamStr(0)) fails in Win2000?
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:
I derive a part of the ExePath path by ExtractFilePath(ParamStr(0)). Could it be that ExtractFilePath(ParamStr(0)) fails in Win2000?
function ShellExecute(hWnd: HWND; Operation, FileName, Parameters, Directory: PChar; ShowCmd: Integer): HINST; stdcall;
function ShellExecute; external 'shell32' name 'ShellExecuteA';
ShellExecute(handle, 'open', Pchar(ExePath) , nil, nil, SW_SHOWNORMAL);
November 25th, 2004, 10:14 AM
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.
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