Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using RunDll32 without Explorer.exe

0 views
Skip to first unread message

John H

unread,
Nov 8, 2001, 12:39:01 PM11/8/01
to
I'm writing a replacement shell for Windows (NT 4, Service Pack 5
and 6). This installs itself simply by replacing the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon with its own executable name. Running
most programs through this shell appears to be no problem, but
when I want to bring up the Printers window, things get very
messy.

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>

Erwin Dokter

unread,
Nov 9, 2001, 3:56:17 AM11/9/01
to
John H wrote:
>
> 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!

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

John H

unread,
Nov 9, 2001, 2:57:05 PM11/9/01
to

"Erwin Dokter" <edo...@home.nl> wrote in message
news:3BEB9A...@home.nl...

|
| Open win32.hlp, and read the Control Panel Applications
overview (from
| the contents tab), you may want to try interfacing directly
into
| main.cpl.

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... :-(

Erwin Dokter

unread,
Nov 9, 2001, 3:21:59 PM11/9/01
to
John H wrote:
>
> 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.....

John H

unread,
Nov 9, 2001, 3:59:49 PM11/9/01
to

"Erwin Dokter" <edo...@home.nl> wrote in message
news:3BEC3A...@home.nl...

| John H wrote:
| >
| > 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.

0 new messages