Shell usage experience

Source: Internet
Author: User

1. Call the system "create shortcuts" Wizard

Is it because VB does not support creating shortcuts? Although you can call vb5stkit. the fCreateShellLink function in Dll is designed for the installer. The default path of the shortcut always starts from the current user's "\ Start Menu \ Programs", that is, if your Windows 95 is attached to drive C, you cannot use the fCreateShellLink function to create a shortcut to drive D.

Now, we will introduce you to an extremely convenient and clever Method: Using Shell statements to call the system "create shortcuts" Wizard.

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

Private Sub commandementclick ()

Open App. Path & "emp. lnk" For Output As #1

Close #1 create a temporary file in the directory where the program is located

Shell "Rundll32.exe AppWiz. Cpl, NewLinkHere

"& App. Path &" emp. lnk"

End Sub

(Note: In Shell statements, NewLinkHere is followed by a space, which is the quotation mark. Otherwise, an error will occur .)

Run the program and click the command button. How can this problem be solved? The "quick release mode" Wizard appears. If the creation is successful, the shortcut takes the temporary file temp. lnk. If you cancel the creation, temp. lnk will automatically disappear. Of course, you can create temp. lnk anywhere on the hard disk. Now you can add a new skill to your program. Enjoy!

Ii. Use of Rundll32.exe

We know that using Shell statements can only call executable files, namely, exe, com, bat, and pif files. What should we do if we want to call other system functions? In this case, the Rundll32.exe provided by Windows is ready to use. Let's take a look at these usage, which may surprise you.

1. To open the control panel file (Timedate. cpl) that sets the system time, run the following code:

Shell "Rundll32.exe

Shell32.dll, Control_RunDLL Timedate. cpl"

As for opening other Control Panel files, I believe you will be able to take a look at the opposite. Try again and change the file name.

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

She11 "Rundll32.exe url. dll, FileProtocolHandler X" (X indicates the file to be run, including the path, the same below.

3. You can also write it to enable ActiveMovie control:

Shell "RUNDLL32.EXE amovie. ocx, Rundll", 1

And use Shell "RUNDLL32.EXE amovie. ocx, Rundll/play X", 1 to directly play the media file.

4. shell "rundll32.exe desk. cpl, InstallScreenSaver X "is of course Screen Saver installed. if you write a screen saver, you can write it in the installer, you do not have to install it in the system directory. As mentioned above, isn't VB a self-fishing "Application Setup Wizard? Its VB source code is put in the "setupkitsetup1" under the installation directory. Study it well. You can make personalized installation programs.

5. Press shift and Right-click a file. The "open mode" option appears in the menu, which may not be a secret. But now, you can use shell "rundll32.exe shell32.dll OpenAs_RunDLL X" to directly call the "open method" box.

6. You can even use this sentence to print files (including all the text and image formats supported by HTML ):

Shell "rundll32.exe MSHTML. DLL, PrintHTML X", 1

How is it? Is there a small reward? Now, you will certainly treat Rundll32.exe, an ordinary file, with a different eye. It is an essential part for system operation! In fact, Shell + Rundll32 can call many other system functions, such as NetMeeting and Telnet. If you are interested, you can go to "my computer \ HKEY_CLASSES_ROOT \" or "My Computer HKEY_LOCAL_MACHINESoftwareCLASSES" in the table, most of the content in this article is copied from there. With enough determination, confidence, and patience, you can discover more valuable things. Good luck!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.