Using VS2005. I'm calling ShellExecute( ) from a DLL (but from a
function other than DllMain) and cannot persuade the function to find
the .exe I want to open. I call it like this:
retval = -1;
retval = (int) ShellExecute(NULL,"open",
"C:\\WINDOWS\\system32\\cmd.exe",
"","", SW_SHOWNORMAL );
if (retval <= 32)
printf("ShellExecute = %d, LastError = %d\n",
retval, GetLastError());
and no matter with what arguments I call ShellExecute( ), it always
returns 2. Here's the printf( ) output from the code above:
ShellExecute = 2, GetLastError = 2
I see from the debugger "Modules" window that shell32.dll is being
loaded. From FileSnoop I see this version info:
File name: C:\WINDOWS\system32\shell32.dll
Display name: shell32.dll
File type: Application Extension
File size: 8,384,000 Bytes (8,188 KB)
File size on disk: 8,384,512 Bytes (8,188 KB)
File attributes: A
Date created: 8/4/2004 7:00:00 AM
Date modified: 8/4/2004 7:00:00 AM
Last accessed: 2/19/2008 8:33:40 AM
and I also see that shell32.dll exports:
...
ShellExecuteA
ShellExecuteEx
ShellExecuteExA
ShellExecuteExW
ShellExecuteW
...
SO: why am I always getting file-not-found from Shell Execute( )?
Thanks!
-- Pete
Does the command prompt open? I presume it doesn't.
Try using my ShellExec test application on your computer to run
cmd.exe and see if that works - it does for me.
http://www.jddesign.f2s.com/freeware_programs.htm#ShellExec
Dave
That's correct. The command prompt does not open.
> Try using my ShellExec test application on your computer to run
> cmd.exe and see if that works - it does for me.
>
> http://www.jddesign.f2s.com/freeware_programs.htm#ShellExec
>
> Dave
It works byootiful! For cmd.exe and any other program I want to run.
What am I doing differently from ShellExec.exe?
Thanks, Dave
-- Pete
That's a very handy set of tools you have. I've bookmarked it.
I can't spot anything obvious, try passing NULL rather than "".
Dave