본문 바로가기

Development/C#

무선인터넷 수신강도 측정

사용자 삽입 이미지


개발을 하다보면, 간혹 무선인터넷의 수신 강도를 측정할 필요가 있습니다.

여러가지 방법이 있겠지만, 가장 손쉽게 구현할 수 있는 WMI 를 사용하도록 하겠습니다.
자세한 방법은 http://msdn.microsoft.com/en-us/library/aa389762(VS.85).aspx 를 참고하시면 됩니다.


필요한 정보는 다음과 같습니다

Namespace : root\WMI
Classes : MSNdis_80211_ReceivedSignalStrength


사용자 삽입 이미지

C# 에서 WMI 를 사용하시는데 별 어려움 없으실 거라고 생각합니다. 위에 보이는 것 처럼 직접 구현해 주셔도 되지만, 개인적으로 귀찮은지라 WMI Code Creator 를 이용해서 Copy & Paste 를 선호합니다.

팁으로 만약 C++ 에서 WMI Application 을 개발하기 위해서는 다음과 같이 하면 됩니다.

Creating a WMI Application Using C++

To create an application for WMI using C++: you must initialize COM, access and set WMI protocols, and perform a manual cleanup. However, C++ does have the advantage of flexibility and power. Therefore, while you are better served in using Visual Basic Scripting Edition (VBScript) or Microsoft JScript for simple processes, C++ works better for more sophisticated applications and is required for writing providers.

The following procedure describes how to create a WMI application.

To create a WMI application

  1. Initialize COM.

    Because WMI is based on COM technology, you must perform calls to the CoInitializeEx and CoInitializeSecurity functions to access WMI.

  2. Create a connection to a WMI namespace.

    By definition, WMI runs in a different process than your application. Therefore, you must create a connection between your application and WMI.

  3. Set the security levels on the WMI connection.

    To use the connection you create to WMI, you must set the impersonation and authentication levels for your application.

  4. Implement the purpose of your application.

    WMI exposes a variety of COM interfaces use to access and manipulate data across your enterprise. For more information, see Manipulating Class and Instance Information, Receiving a WMI Event, and COM API for WMI.

    This is where the bulk of your WMI client application should exist, such as accessing WMI objects or manipulating data.

  5. Cleanup and shut down your application.

    After you complete your queries to WMI, you should destroy all COM pointers and shut down your application correctly.

For more information and a code example about how to create a WMI application, see Example: Creating a WMI Application.



이해가 잘 안간다면 하단에 나와 있듯이 Example: Creating a WMI Application 를 보면 한눈에 방법을 알 수 있다.