Using Visual Basic to Create Sample DLL and EXE Files

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office

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

  1. From Visual Basic, create a New Project (select ActiveX DLL as the project type).
  2. Rename the project as "DllTest" and the class module as "TestSxS"
  3. From the Project menu, select References.
  4. From the list of available references, select Microsoft XML, v5.0.
  5. 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
  6. 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.

  7. If you will be using and testing DllTest.dll on this computer, you need to unregister it. To unregister DllTest.dll, do the following:
    1. Open a command prompt window and change the directory to the folder that you used in Step 6.
    2. 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

  1. From Visual Basic, create a New Project. Select Standard EXE as the project type.
  2. Rename the project as "MyTestApp".
  3. From the Project menu, select References.
  4. 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.

  5. Create a command button (Command1) on Form1 and change its Caption property from "Command1" to "Test DLL".
  6. 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
  7. 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