Microsoft KB Archive/247987

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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:


  1. Create a Standard EXE project in Visual Basic.
  2. Add the WMI Login control and WMI Namespace Picker control components to the project.
  3. Add an instance of each of these controls to the Visual Basic form. The default names for the controls are Login1 and NamespacePicker1.
  4. 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 
  5. Generate the EXE for the project and run it.
  6. Click the Computer icon on the Namespace Picker control.
  7. 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
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.