|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Download MyComDll.zip - 391.71 KB IntroductionIn my previous article "Creating COM DLL with VS 2005 Walk-Through", we walked-through creating a COM DLL with Visual Studio 2005, using Visual Basic.NET. In this article, we are going to walk-through registering our COM DLL. BackgroundIf your an experienced developer, and you've worked with DLL's before, you've probably already tried using RegSvr32, and have experienced some difficulties. If you're an experienced .NET developer, you may have tried using RegAsm, and have encountered some challenges there as well. In this article, we are not going to look at the more complex approaches of registering a COM DLL. Instead, we are going to walk-through creating a VS 2005 Installer, which will both install and register our COM DLL for us, while providing a simple, professional tool to accomplish this task. As a professional software developer, and an experienced COM DLL developer, I personally prefer using an Installer. Additionally, my clients appreciate it, because whenever they need to install a COM DLL, they are able to. Creating the Setup ProjectIf you followed along with my previous article "Creating COM DLL with VS 2005 Walk-Through", then open that project now. If you did not follow my previous article, but have your own COM DLL that you have created, then open the project that contains that COM DLL now. To begin with, let's add a new "Setup and Deployment" project to our solution:
The Add New Project window: Now that the new "Library Installer" setup project has been added to the Solution, your Solution Explorer should look like the picture below. If Solution Explorer is not open, then open it by clicking on View menu | Solution Explorer. Configure Installer PropertiesNow that we have the installer added to the solution, let's configure it's properties.
Here's the Properties Window: Add Project Output to InstallerThe next thing we need to do is add the files that we want to the installer to install, which in this case is our COM DLL. The installer will not only install our COM DLL, but it will take care of registering it for us as well! First, make sure your "File System" tab is visible. If it's not, follow these steps:
Next, Configure the File System:
When you've added all of the folders, the File System should look like this: Just a brief explanation: What we are doing is, we are telling the installer to install our COM DLL in the following location: C:\Program Files\Common Files\My Libraries.
When you're finished, it should look like this: Finally Save and Build both projects.
Run the Installer from within Visual StudioWe have finished our installer! Now we are ready to test it out!
When you run the Installer, observe the following:
Using our registered COM DLL in VB6We now have a registered COM DLL ready to be used in VB6. Let's go into VB6 and see how to use it. Create a new VB6 Project:
Add a reference to our COM DLL:
Finally, in the Click() event for our Command Button, add code to utilize our COM DLL: Private Sub Command1_Click()
Dim mcc As New MyComClass
mcc.DisplayMessage
End Sub
Here's the results of our test:
ConclusionAs you can see, creating a Setup project to install and register your COM DLL is very easy with VS 2005! Additionally, it is very easy for anyone to use, and looks very professional! I hope this article is helpful to you! VBRocks
|
|||||||||||||||||||||||||||||||||||||||||||||||