Microsoft KB Archive/827017

= HOW TO: Obtain the COM Registration Information in a Windows Installer Package by Using Microsoft Visual Studio .NET =

Article ID: 827017

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Windows Installer 2.0
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-



IN THIS TASK

 * SUMMARY
 * Requirements
 * Create a Setup Project
 * Add a Windows Application to the Setup Project
 * Add a Registry Launch Condition to the Setup Project
 * Verify That Your Application Works
 * REFERENCES



SUMMARY
This step-by-step article discusses how to obtain the COM registration information in a Microsoft Windows Installer package by using Microsoft Visual Studio .NET. You set registry launch conditions in your Visual Studio .NET Setup project to determine if the COM component is registered.

If you set registry launch conditions, AppSearch searches the registry for the COM registration, and then returns the search results as a property while installing the package. If the registry entry does not exist on your computer, the launch condition uses this property to quit the installation process.

In the sample, you create a Visual Studio .NET Setup project. In this project, you set the registry launch condition to search for the registry entry of the Mscorlib.dll file on your computer. If the Mscorlib.dll file is not registered on your computer, the launch condition quits the installation of the Windows Installation package.

back to the top

Requirements
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
 * Microsoft Windows 2000, Microsoft Windows XP, or Microsoft Windows Server 2003
 * Microsoft Visual Studio .NET

This article assumes that you are familiar with the following topics:
 * Visual Studio .NET Setup Projects
 * Launch Conditions

back to the top

Create a Setup Project
To create a Setup project by using Visual Studio .NET, follow these steps:
 * 1) Start Microsoft Visual Studio .NET.
 * 2) On the File menu, point to New, and then click Project.
 * 3) Under Project Types, click Setup and Deployment Projects.
 * 4) Under Templates, click Setup Project.
 * 5) In the Name text box, type MyApp, and then click OK.

back to the top

Add a Windows Application to the Setup Project
To add a Windows Application project to the Setup project, follow these steps:  On the File menu, point to Add Project, and then click New Project. Under Project Types, click Visual Basic Projects. Under Templates, click Windows Application. In the Name text box, type MyWindowsApp, and then click OK. Add a Button control to Form1. By default, Button1 is created.  Add the following code to the Button1_Click event handler: MessageBox.Show(&quot;This is a test Windows Application&quot;)  In Solution Explorer, right-click MyWindowsApp, and then click Build.</li> In Solution Explorer, right-click MyApp, point to Add, and then click Project Output.</li> In the Add Project Output Group dialog box, click OK.</li></ol>

back to the top

Add a Registry Launch Condition to the Setup Project
To add a registry launch condition that searches for the registry entry of the Mscorlib.dll file based on the registry key that you provide in the Setup project, follow these steps: <ol> In Solution Explorer, right-click MyApp, point to View, and then click Launch Conditions.</li> In the Launch Conditions Editor, right-click Requirements on Target Machine, and then click Add Registry Launch Condition.</li> Right-click Search for RegistryEntry1, and then click Properties Window.</li> In the Properties window, verify if the Root property is set to vsdrrHKLM.</li> Set the RegKey property to the following:

SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\9CD7C0343CB3E804297298BEA362A56C

</li> Set the Value property to the following:

AA75334BD6A349D45BE6344CD4905E84

</li> Right-click Condition1, and then click Properties Window.</li> In the Properties window, set the Condition property to the following:

REGISTRYVALUE1<>&quot; &quot;

</li> Set the Message property to the following:

Mscorlib.dll is not registered. Register the component to continue.

</li> In Solution Explorer, right-click MyApp, and then click Build.</li></ol>

back to the top

Verify That Your Application Works
<ol> Locate the MyApp.msi file in the MyApp\Debug folder on your computer.</li> Right-click MyApp.msi, and then click Install.</li> If the Mscorlib.dll file is not registered on your computer, you receive the following message and the installation process is not completed:

Mscorlib.dll is not registered. Register the component to continue.

</li></ol>

back to the top

<div class="references_section">