Search Tools Links Login

Context Menu (Un)Register OCX and DLL



I'm still new to creating ActiveX DLL. After downloading some DLL plugin samples from Planet-Source-Code i found that some of the codes need to register the DLL manually (that is typing "c:windowssystem egsvr32.exe DLLFILENAME" in MS-DOS prompt) or an extra EXE is created for that purpose. Why not add an "Register DLL" option into context menu (the menu which pops up when you right click on any dll files with your mouse on right panel of Windows Explorer)?

Original Author: Chin Huat

Code





  1. Click on Start Menu, choose "Run".
  2. Type "regedit" and click "OK".
  3. On the left panel of Registry Editor, go to :


    My ComputerHKEY_CLASSES_ROOTdllfile


    (expand the tree with alot of folder icons, from "My Computer", then "HKEY_CLASSES_ROOT" and then "dllfile", by clicking the "+" sign)
  4. Right click on "dllfile", choose "New" -> "Key".
  5. Rename the new key to "shell". IT SHOULD BE AT THE SAME LEVEL AS THE "DefaultIcon" KEY!

  6. Create another key named "Register" under "shell"
  7. On the right panel, set "(Default)" string value into "Register DLL" by double clicking on it.
  8. Create another key named "command" under "Register"
  9. Again, set the "(Default)" string value under "command" to:


    C:windowssystem egsvr32.exe "%1"


  10. Restart your computer.
  11. Now, right-click on some DLL files, there should be an extra option "Register DLL". Click on it.
  12. A message box will appear, displaying the success message.

Just in case you want to add another option called "Unregister DLL", you can create another key named "Unregister" under "shell" ("Unregister" should be the same level as "Register") and set the "(default)" string value to "Unregister DLL". Under "Unregister", create another key called "command" and set the "(default)" string value to


????C:WindowsSystemRegSvr32.Exe /u "%1"


Restart your computer. "Unregister DLL" should be available in context menu. The same trick applies to all file types. Let me know if you still have any problem.









Note:

  1. To make the same option available for .OCX files, search for "ocxfile" key under "HKEY_CLASSES_ROOT" and repeat step 4 to 12
  2. Let say if you want to add a shell option to a file with extension .ABC , you must find the ".ABC" key under "HKEY_CLASSES_ROOT". Memorize the default value under the key, (eg, "(Default)" is set to "ABCFile"). Find the key with the same same as the value (in this case, the key name is "ABCFile"). Now repeat from step 4 to 12. IF YOU CREATE THE "shell" key under ".ABC", THINGS WILL NOT WORK OUT!
  3. Backup your registry file so that you can restore them, just in case anything worse happen. Choose "Registry" from the menu, then "Export Registry File". The rest should be self explainable.
  4. Windows ME (and 2000?) already have this built-in function. The "Open With" context menu option now contains "Microsoft(C) Register Server". Clicking on it will register the DLL only but not unregister it!

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 214 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.