1. RunDLL32
Hi everyone,
I always wanted to contribute something. So here's mine.
It's something I grabbed from a web page while surfing. I hope somebody
would find this usefull.
Regards,
Arlie
...
...
Rundll32
To access the other Windows functions, we will use a small program that
allows us to access functions in EXE=92s and DLL libraries. The Rundll32
program is a Windows program that enables us to run DLL=92s as if they were
normal exe=92s and to access their built-in functions. We can only do this,
obviously if the DLL was designed to do that and has the specific function
that we want to access.
NOTE: not all functions can be accessed this way, only a few. That is why
this is called a Windows secret.
For example, our top right pushbutton is called =93Tile Windows=94. This wou=
ld
tile all child Windows that have the Windows Desktop as their parent. In
other words, all Windows inside a main Window. We could do this via an API
call. But that needs a bit of API understanding. Our first secret will be
to place the following code in the pushbutton's onClick event:
run(.t., "rundll32 user,tilechildwindows")
The =93tilechildwindows=94 is a function found in the user library. The
Rundll32 enables us to access that library, and the .t. parameter tells the
run() function that it is a Windows command. Notice that the entire command
is between quotes, and that there is no space before and after the comma.
We can do a similar thing with cascading windows e.g.,
run(.t., "rundll32 user,cascadechildwindows")
Not all functions are contained in the =93user=94 library. For instance, we =
can
access the standard Windows Control panel by using:
run(.t., "rundll32 shell32,Control_RunDLL")
You will notice that we are accessing a different library,
namely =93shell32=94. If you are used to accessing the API you will then
recognise these. The =93Control_RunDLL=94 function is what actually opens th=
e
Control Panel. We can also open individual Control Panel applets. In the
Windows' System subdirectory, you will notice a whole bunch of files with a
cpl extension. These are the individual Control Panel applets. If we would
like to change the display properties, we could do this without opening the
Control Panel by simply using the following command:
run(.t., "rundll32 shell32,Control_RunDLL desk.cpl")
You will notice that the command is similar to the previous one, except for
an added parameter, the name of the Control Panel applet that we want to
run.
You might also notice that there are some Control panel applets that don=92t=
have a corresponding *.cpl file. For example, you won't find a mouse.cpl or
a printers.cpl. This is because, if I understand correctly, they are
contained in the main.cpl file. What we would do is use the command as
above, substitute desk.cpl with main.cpl and then add an extra parameter to
signify which applet we want to run. The name normally would be the same as
you would find in the Control Panel. By putting this into a combobox on our
form, we can give the user a choice. In the form included with this
article, I gave you the choice of four Control Panel applets (Mouse, Fonts,
Keyboard and Printers). If your Windows is for a language other than
English, replace them in the Combobox1 dataSource with their equivalent in
your own version of Windows.
Comboselect=3Dform.combobox1.value
run(.t.,"rundll32 shell32,Control_RunDLL main.cpl "+Comboselect)
return
So now we can run individual Control Panel applets. Neat hey!
The Rest
Now that you have got the picture, study the code as I briefly explain the
rest of the pushbuttons and the functions that they employ.
Copy Disk
Brings up a dialog box enabling you to copy a disk (i.e. from A: to B: or
A: to A:)
run(.t., "rundll32 diskcopy,DiskCopyRunDll")
return
Format Drive
This one sounds very scary, but it=92s really not. It is exactly the same as=
if you right click on the A: drive and select format. It will bring up a
dialog that will enable you to choose the floppy media to format and also
give you a chance to cancel. It will not allow you to format C:, no such
option. Use with caution.
run(.t., "rundll32 shell32,SHFormatDrive")
return
Open File With...
When you try to open a file that does not have a program associated with
it, the =93open with=94 dialog box appears, enabling you to select the
application you wish to use to open that particular file. Here, this
pushbutton opens that dialog box.
run(.t., "rundll32 shell32,OpenAs_RunDLL")
return
Exit Windows
Shuts Windows down to a safe position to power off.
run(.t., "rundll32 shell32,SHExitWindowsEx 1")
return
Exit Windows2
Shuts Windows down and turns off the power. Your PC must support this
function.
run(.t., "rundll32 user,ExitWindows")
return
Log Off
Self-explanatory. Logs the current user off and restarts Explorer, or
Windows.
run(.t., "rundll32 shell32,SHExitWindowsEx 0")
return
Reboot
Self-explanatory. Forces a reboot of the PC, everything is shut down
cleanly.
run(.t., "rundll32 shell32,SHExitWindowsEx 2")
return
Restart Explorer
Similar to the reboot. Restarts Explorer, or restarts Windows without
actually exiting the windows GUI.
If MsgBox("All unsaved work will be lost! Do You want to
continue?","Caution!",52)=3D6
run("rundll32 shell32,SHExitWindowsEx -1")
endif
return
Force shutdown
This is a strange one. It will force a shutdown by closing the kernel. The
machine will appear to hang but a reset will not force a scan disk as it
would do after a bad shutdown. This is because closing the kernel flushes
all buffers.
If MsgBox("All unsaved work will be lost! Do You want to
continue?","Caution!",52)=3D6
run("rundll32 krnl386.exe,exitkernel")
endif
return
Add Hardware
Runs the install device dialog from the installing new hardware Applet
wizard in Control Panel.
run(.t., "rundll32 sysdm.cpl,InstallDevice_Rundll")
return
System Crash
Simulates a crash. Do we really have to simulate a Windows crash? Be
warned this will cause your system to hang. You will have to reset.
If MsgBox("All unsaved work will be lost! You will have to reset. Do You
want to continue?", "Caution!", 52)=3D6
run(.t., "rundll32 user,disableoemlayer")
endif
return
Repaint Screen
Self explanatory. Refreshes or repaints the screen.
run(.t., "rundll32 user,repaintscreen")
return
Print Test page
Prints a test page. If you have multiple printers, you can select one. The
default printer will be highlighted.
run (.t., "rundll32 msprint2.dll,RUNDLL_PrintTestPage")
return
Cursor Blink
Change the cursor blink rate. The only problem is that I can=92t figure out
what the value should be, also once the cursor is blinking I can only get
it back to normal via the keyboard applet in the Control Panel.
run(.t., "rundll32 user,setcaretblinktime")
return
Disable mouse
You might want to, or you might not want to use this; anyway, this will
disable the mouse. The enable parameter does not seem to work. The mouse
will only be disabled after reboot. You can reset it via the Control Panel.
If MsgBox("Disabled mouse will be functional only after rebooting! Do You
want to continue?", "Caution!", 52)=3D6
run(.t., "rundll32 mouse,disable")
endif
return
Swap Buttons
Swap the mouse button actions from left to right for left handed people. If
click select action is on the left mouse button, it will now be on the
right button. Reset via the Control Panel mouse applet.
run(.t., "rundll32 user,swapmousebutton")
return
Disable Keyboard
Use with caution! Same as the mouse function above, but this will disable
the keyboard. The enable parameter does not seem to work.
If MsgBox("Disabled keyboard will be functional only after rebooting! Do
You want to continue?", "Caution!", 52)=3D6
run(.t., "rundll32 keyboard,disable")
endif