# VBForums CodeBank > CodeBank - Other >  [Tip] Register/Unregister DLLs and OCXs easily

## mendhak

Instead of having to do a 



```
regsvr32 "c:\whatever\something.dll"
```

 for each dll you need to register, it's easier to have a "Register/Unregister" option in the right click menu for DLLs.  

Create a reg file, and add the following to it:



```
REGEDIT4

[HKEY_CLASSES_ROOT\dllfile\Shell]
@="Register"

[HKEY_CLASSES_ROOT\dllfile\Shell\Register]

[HKEY_CLASSES_ROOT\dllfile\Shell\Register\command]
@="regsvr32.exe %1"

[HKEY_CLASSES_ROOT\dllfile\Shell\Unregister]

[HKEY_CLASSES_ROOT\dllfile\Shell\Unregister\command]
@="regsvr32.exe /u %1"

[HKEY_CLASSES_ROOT\.ocx]
@="ocxfile"

[HKEY_CLASSES_ROOT\ocxfile]
@="OCX File"
"EditFlags"=hex:00,00,01,00

[HKEY_CLASSES_ROOT\ocxfile\Shell]
@="Register"

[HKEY_CLASSES_ROOT\ocxfile\Shell\Register]

[HKEY_CLASSES_ROOT\ocxfile\Shell\Register\command]
@="regsvr32.exe %1"

[HKEY_CLASSES_ROOT\ocxfile\Shell\Unregister]

[HKEY_CLASSES_ROOT\ocxfile\Shell\Unregister\command]
@="regsvr32.exe /u %1"
```

Then, run the .reg file, and the next time you right click a DLL or OCX, the option to register or unregister it should be there.  Note that "Register" becomes the default option in the right click menu when you run the .reg file.  

I found this useful, and thought I'd share it with all of you here.  :Smilie:

----------


## Tek

Thx this will save lots of time lol.

----------


## mendhak

Micro$oft should've included this behavior by default, me thinks.  :Cool:

----------


## JPicasso

Who says no good code comes out of Ulaan Baator?

----------


## kleinma

thanks mendhak... now get back to chit-chat where you belong  :Big Grin:

----------


## satti charvak

do you have any leg problems......coz all people who have mendhak as nickname do have leg problems......all though thay have excellent ideas to leap around.......

good help boss for ocx registration..

----------


## mendhak

> _Originally posted by JPicasso_ 
> *Who says no good code comes out of Ulaan Baator?*


*raises hand*

----------


## jemidiah

Are you really from Mongolia then?

----------


## MartinLiss

mendhak: Would you like me to m ove this thread to the CodeBank?

----------


## mendhak

Your discretion Martin.  If you see it fit to move it there, go ahead.  :Smilie:

----------


## mendhak

Or should I create a copy of this in Code Bank - Other so that some of the members can see this here too?

----------


## binduau

Awesome Tip

 :LOL:  

bindu




> _Originally posted by mendhak_ 
> *Instead of having to do a 
> 
> 
> 
> ```
> regsvr32 "c:\whatever\something.dll"
> ```
> 
> ...

----------


## Spajeoly

What I did was just right click on one > Open With, Select Regsvr32.exe and select to always open this type of file with this program.

But good tip.

----------


## jeremy_ckw

Heh... :Smilie:  How do I undo this? Just delete all the registry entries?

----------


## mendhak

Nope.  You're stuck with it forever now!  Mwahah!! :evil:











































Yeah, just delete the registry entries.

----------


## jeremy_ckw

> _Originally posted by mendhak_ 
> *Nope.  You're stuck with it forever now!  Mwahah!! :evil:
> 
> 
> 
> 
> 
> 
> 
> ...


Very funny...hahahha....well...thanks for the great tips, mate!

----------


## kleinma

too bad theres not a way to only have it show on files that can actually be registered/unregistered instead of all DLLs

----------


## crptcblade

> _Originally posted by kleinma_ 
> *too bad theres not a way to only have it show on files that can actually be registered/unregistered instead of all DLLs*


That's not really true, its just a lot harder to accomplish.

http://www.vbforums.com/showthread.p...hreadid=190107
http://www.vbforums.com/showthread.p...hreadid=242824

----------


## mendhak

Whoops. 

Got kicked so hard it duplicated itself.  :Ehh:

----------


## Madboy

Does it matter where you put this registry key in the registry?

----------


## CornedBee

On 2k and XP you can put it in
HKEY_LOCAL_MACHINE/Software/Classes
so that every user has it, or in
HKEY_CURRENT_USER/Software/Classes
so that only you have it.

But the stuff mendhak posted automatically places itself in
HKEY_CLASSES_ROOT
so I don't know which case applies.


It would be possible to associate this stuff only with DLLs that CAN be registered, I could even write something like it. Question is, do I care?

----------


## Madboy

So i can pop it in anywhere? :Confused:

----------


## CornedBee

As mendhak said, put this stuff into a .reg file. It will know where to place itself.

----------


## Madboy

Where do you get the .reg files from though? They aint in any of my windows context menu's

----------


## CornedBee

Fire up notepad, copy and paste the code from here and save as a .reg.

----------


## Madboy

Cheers dude :wave:

----------


## csar

It should have quote sign " around %1 to ignore the error when dll file was stored in directory that had space in name.


regsvr32.exe %1

,should be this

regsvr32.exe "%1"


lol

----------

