常州市润邦电子科技有限公司

热保护器测试专业供应商

 

How to Register an ActiveX DLL on Vista with regsvr32

How to Register an ActiveX DLL on Vista with regsvr32

Let me begin by saying: Vista = pain + time + frustration.

This article will get you through the minefield of registering an ActiveX DLL with regsvr32 on Vista. I’ll step you through all the pitfalls…

1) First, create a .bat in the same directory as your DLL. Add this single line to your .bat:

regsvr32 myThingy.dll

Now run it. Here’s the error message you’ll get:

The module "myThingy.dll" was loaded but the call to DllRegisterServer failed with error code 0×8002801c.

For more information about this problem, search online using the error code as a search term.

When will Microsoft learn that error codes suck? They’re useless. Perhaps a message such as "Security paranoid Vista didn’t let you register the DLL because writing to the registry is extremely dangerous." would be better, because that’s exactly what 0×8002801c means. Isnt’ it obvious? (Also — isn’t Microsoft adding to Google’s dominance of the search market by telling programmers to "search the web"?)

2) OK, you’re smart and you know how to get around this problem. Right-click the .bat file and choose "Run as Administrator". That ought to do it!

But now you get this error (after you click on yet another dialog box giving permission to continue):

The module "myThingy.dll" failed to load.

Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.

The specified module could not be found.

OK, at least you didn’t get an error code. But it’s worse — you’ve been misdirected. You’re reasoning will be this: My specified path is the current working directory because I didn’t specify a path for my DLL, and since the .bat file is located in the same directory as my DLL, it must be OK.

So now you fire up "depends.exe" and check to see what it says. Aha! There’s the missing dependency — dwmapi.dll!
What is it and why is it missing on my system? You waste the rest of the afternoon trying to track it down, but to no avail…

It turns out that dwmapi.dll is not the problem at all. The real problem is that when regsvr32 runs, it’s current working directory changes to \Windows\System32 — so it couldn’t find your myThingy.dll after all!

Change your .bat script to use the full, absolute path. For example:

regsvr32 c:\myApp\myThingy.dll

Right-click on the .bat, select "Run as Administrator", give permission to Vista to continue however often it asks, and voila! The DLL is registered.

That was easy. I love Vista.

posted on 2010-12-21 13:48  常州市润邦电子科技  阅读(480)  评论(0编辑  收藏  举报

导航