HOWTO: Connect to Windows Management Instrumentation (WMI) Using the WMI ActiveX Controls |
Q247987
The information in this article applies to:
- Windows Management Instrumentation, versions 1.1, 1.5
SUMMARY
The Windows Management Instrumentation (WMI) ActiveX controls that require a connection to WMI have an event called GetIWbemServices that is triggered when the control needs to connect to a WMI namespace. To provide the connection, use the GetIWbemServices method of the WMI Login control (WBEMLogin.ocx).
Note: In WMI version 1.1, these controls are known as WBEM controls. In WMI version 1.5, they are known as WMI controls.
MORE INFORMATION
Here is a simple procedure to create a Visual Basic form that uses the WMI Namespace Picker control and the WMI Login control to connect to WMI:
- Create a Standard EXE project in Visual Basic.
- Add the WMI Login control and WMI Namespace Picker control components to the project.
- Add an instance of each of these controls to the Visual Basic form. The default names for the controls are Login1 and NamespacePicker1.
Add the following event handler for NamespacePicker1:
Private Sub NamespacePicker1_GetIWbemServices(ByVal lpctstrNamespace As String, pvarUpdatePointer As Variant, pvarServices As Variant, pvarSC As Variant, pvarUserCancel As Variant) Login1.GetIWbemServices lpctstrNamespace, pvarUpdatePointer, pvarServices, pvarSC,pvarUserCancel End Sub
- Generate the EXE for the project and run it.
- Click the Computer icon on the Namespace Picker control.
- Press the Connect button on the Browse for Namespace dialog. This triggers the GetIWbemServices event of the Namespace Picker control, and the event handler then uses the Login control to connect to WMI.
NOTE: Due to an incompatibility between the Visual Basic debugging environment and the WMI Namespace Picker control, you must generate an EXE in order to use the control. You cannot use it within the Visual Basic debugger. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
Q244604 WBEM Namespace Picker Control Does Not Connect to WMI in Visual Basic IDE
REFERENCES
For more information, see the Windows Management Instrumentation SDK documentation in the Platform SDK.
Additional query words: wmi wbem login connect activex
Keywords : kbVBp kbWMI110 kbWMI150
Issue type : kbhowto
Technology : kbWMISearch kbAudDeveloper kbWMI110 kbWMI150
Last Reviewed: March 19, 2000 |