SHELL statement method

xiaoxiao2021-03-06  119

SHELL statement method

I. Call the system "Create Shortcut" Wizard

Is it urgent to create a shortcut for VB? Although you can call the FcreateshellLink function in vb5stkit.dll,

But it is designed for installation program, shortcut the default path always starts from the current user's "/ start menu / programs", that is,

If your Windows95 is mounted on the C drive, you cannot create a shortcut to the D disk through the Fcreates Helllink function.

Now, give you an extremely convenient and clever way: call the system "Create Shortcut" wizard with the shell statement.

Create a new project, put a button on the form, double-click this button, add the following code:

Private submmand1_click ()

Open app.path & "/temp.lnk" for Output AS # 1

Close # 1 'The above two sentences create a temporary file in the directory where the program is located

Shell "rundll32.exe appwiz.cpl, newlinkhere" & app.path & "/temp.lnk"

End Sub

(Note: NEWLINKHERE in the shell statement is quotation number, otherwise it will be wrong.)

Run the program, press the command button, how? The "Create Shortcut" wizard appears, if you have successful, shortcuts will take

The location of the temporary file TEMP.LNK, if the selected cancel, TEMP.LNK will automatically disappear. of course,

You can establish Temp.Lnk in any location of the hard disk. Ok, now you can add a new feature to your program. Enjoy!

II. Use of Rundll32.exe

We know that the executable can only be called with the shell statement, that is, EXE, COM, BAT, and PIF files.

Sometimes we want to call other system functions? At this point, Rundll32.exe provided by Windows can be big.

Below let's meet these usage, you may bring you a little surprise.

1. To open the setting system time control panel file (TIMEDATE.CPL), just run the following code:

Shell "rundll32.exe

Shell32.dll, control_rundll timedate.cpl

As for opening other control panel files, I believe that you will be able to raise a non-three, try it, change the file name.

2. To run a shortcut (* .lnk), you can use the following code:

She11 "Rundll32.exe Url.dll, FileProtocolhandler X"

(X represents the file to run, including the path, the same.)

3. You can also write this to open ActiveMovie control:

Shell "Rundll32.exe Amovie.ocx, Rundll", 1

Use shell "rundll32.exe amovie.ocx, Rundll / Play X", 1 will play a media file directly.

4. Shell "rundll32.exe desk.cpl, installscreensaver x" is of course installation screen protection,

If you write a screen saver, you can write it in the installer, and don't have to install it under the system directory.

By the way, VB is not a "Application Setup Wizard"? Its VB source code is in the installation directory

"/ Setupkit / setup1" put it, study it. You can do a personalized installer.

5. Press and hold the Shift key, right click on a file, and the "Open Mode" option will appear in the menu, which may be no secret. but now,

Use shell "rundll32.exe shell32.dll OpenAS_RUNDLL X" to directly call the "Open Mode" box.

6. Can even use such a sentence to print the file (including all text supported by HTML and image format):

Shell "Rundll32.exe Mshtml.dll, Printhtml X", 1

how about it? Is it a small harvest? This, you will definitely treat Rundll32.exe this usually,

It is an essential component that is running in the system! In fact, shell rundll32 can also call many other system functions.

For example, about NetMeeting and Telnet. If you are interested, you can

Go to the applet "My Computer / HKEY_CLASS_ROOT /", "My Computer / HKEY_LOCAL_MACHINE / SOFTWARE / CLASSES" to see,

The content of this article is mostly "copying" there. As long as there is enough determination, confidence, patience, you must find more valuable things. Good luck!

转载请注明原文地址:https://www.9cbs.com/read-105179.html

New Post(0)