Using Visual Basic to Create Sample DLL and EXE files
In Creating a Manifest for Your Component DLL you are given instructions on how to author a manifest and test side-by-side installation of your component DLL that uses MSXML 5.0. The process requires you to have or make a simple EXE that uses another small DLL, which in turn, depends upon MSXML 5.0. Since you need these files to test side-by-side installation under Windows XP, the procedures in this topic provide you instructions for how to generate those files.
To create DllTest.dll using Visual Basic
- From Visual Basic, create a New Project (select ActiveX DLL as the project type).
- Rename the project as "DllTest" and the class module as "TestSxS"
- From the Project menu, select References.
- From the list of available references, select Microsoft XML, v5.0.
- Paste the following code in the TestSxS class module:
Option Explicit Private xmlDoc As MSXML2.DOMDocument50 Private mvarIt As String Public Property Let It(ByVal vData As String) mvarIt = vData End Property Public Property Get It() As String Set xmlDoc = New DOMDocument50 xmlDoc.async = False xmlDoc.loadXML "<" & mvarIt & "/>" It = xmlDoc.xml End Property Private Sub Class_Initialize() mvarIt = "test" End Sub Private Sub Class_Terminate() Set xmlDoc = Nothing End Sub
- From the File menu, select Make DllTest.dll.
Select a folder on your computer (such as c:\temp) where you want the compiled DllTest.dll file to be placed, and then click OK.
- If you will be using and testing DllTest.dll on this computer, you need to unregister it. To unregister DllTest.dll, do the following:
- Open a command prompt window and change the directory to the folder that you used in Step 6.
- Type "regsvr32 /u DllTest.dll", and then press Enter.
Note Visual Basic automatically creates the type library for a project, and registers the DLL globally on your development computer when you create it. If you copy DllTest.dll directly from your computer to another computer to test it with your application, you can skip this step.
To create MyTestApp.exe using Visual Basic
- From Visual Basic, create a New Project. Select Standard EXE as the project type.
- Rename the project as "MyTestApp".
- From the Project menu, select References.
- Click Browse. Browse to the location where you created DllTest.dll in the previous procedure, and select it.
You should see DllTest selected in the list of available references. After you do, click OK.
- Create a command button (Command1) on Form1 and change its Caption property from "Command1" to "Test DLL".
- Double click on the Command1 button and enter code in the Form1 module to match the following:
Private Sub Command1_Click()
Dim MyObject As New DllTest.TestSxS
MyObject.It = "test"
MsgBox MyObject.It
End Sub - From the File menu, select Make MyTestApp.exe.
Select the same folder on your computer where you created DllTest.dll (such as c:\temp). Click OK.
See Also
Creating a Manifest for Your Component DLL