I use the command H:= ShellExecute(Handle, 'Open',
'rundll32.exe', 'shell32.dll,Control_RunDLL main.cpl,@2', '',
SW_NORMAL);
or alternatively
H:= ShellExecute(Handle, 'Open', 'rundll32.exe',
'shell32.dll,Control_RunDLL main.cpl @2', '', SW_NORMAL);
- with H being a THandle. Both of the above seem to have the same
result. If Explorer.exe (the standard Windows shell) is already
running, this works fine. If it's not, I get an unwanted call to
Explorer, with the standard Windows taskbar popping up, and an
error message on the lines of "Cannot find the file
'/idlist,:100:184' or one of its components".
Subsequent calls to the ShellExecute line above work, but
Explorer.exe is then running in the background, which defeats the
object of an alternative shell. This suggests that rundll32.exe
needs to have Explorer running. Obviously there is some
initialisation needed, that my shell isn't doing - but I can't
find any documentation for this. Is there any way of running
control or main.cpl directly, so that Explorer.exe doesn't pop up
unwanted?
I've tried preceding the call with LoadLibrary(PChar('main.cpl');
but this is obviously too simplistic. Any suggestions? I'd be
extremely grateful for any help!
--
John Hudson, Gateshead, UK <jo...@saltwell.demon.co.uk>
Tricky business... It's not rundll.exe that needs Explorer running, but
shell32.dll. Open control.exe in notepad, and you will find all it does
is what you do above. 'Control Panel' is now tightly integrated into the
Explorer, as it relies on Explorer's user interface to show the icons
and property sheets.
Open win32.hlp, and read the Control Panel Applications overview (from
the contents tab), you may want to try interfacing directly into
main.cpl.
-- Erwin Dokter
mailto:edo...@home.nl
http://members.home.nl/edokter
Thanks for this - but the Control Panel Applications Overview
doesn't seem to be in my help for Delphi 3: maybe it was
introduced later. I'll check out the files with Delphi 5 at
work... :-(
It is in my win32.hlp that came with Delphi 2.....
Thanks - found it eventually by opening up this file directly.
However, it isn't very helpful as it just focuses on writing the
application to be called. When it comes to calling it, it seems
to assume you will use the standard interface through shell32.dll
and control.exe. And (as is usual with the Windows help files)
there are no code examples, even in C.
Because of this, I'd still be grateful to hear from anyone else
who might have accomplished this task (opening up the printers
window without having explorer.exe running in the background) or
could point me to examples of code.