System.ServiceProcess 네임 스페이스를 사용한다
 

private void InitList()
{
  ServiceController [] controllers = ServiceController.GetDevices();
  int nNum = controllers.Length;
  string strType = new String ("");
  m_wndDriversList.ListItems.Clear ();

  for (int i = 0; i < nNum; i++)
  {
    ListItem item = new ListItem ();
    // 서비스의 짧은 이름을 가져온다..
    item.Text = controllers[i].ServiceName;
    // 서비스의 긴 이름을 가져온다..
    item.SetSubItem (0, controllers[i].DisplayName);
    // 서비스 타입을 가져온다.
    ServiceType type = controllers[i].ServiceType;

    switch (type)
    {
      case ServiceType.Adapter:
      strType = "Adapter";
      break;

      case ServiceType.FileSystemDriver:
      strType = "File System Driver";
      break;

      case ServiceType.InteractiveProcess:
      strType = "Interactive Process";
      break;

      case ServiceType.KernelDriver:
      strType = "Kernel Mode Driver";
      break;

      case ServiceType.RecognizerDriver:
      strType = "Recognizer Driver";
      break;

      case ServiceType.Win32OwnProcess:
      strType = "Win32 Process";
      break;

      case ServiceType.Win32ShareProcess:
      strType = "Win32 Share Process";
      break;

      default:
      strType = "Unknown";
      break;
    }
    item.SetSubItem (1, strType);

    //서비스의 동작 여부를 알아온다.

    item.SetSubItem (2, (controllers[i].CanStop == true) ? "Yes" : "No");
    m_wndDriversList.ListItems.Add (item);
  }
}

출처 : http://www.mkexdev.net

'IT' 카테고리의 다른 글

Prototype Javascript Framework  (0) 2009.02.16
VS 단축키  (0) 2009.02.09
문자열 가지고 놀기~  (0) 2009.02.09
윈폼or모듈단위에서 특정 웹페이지 호출하기(with param)  (0) 2009.02.09
인증 성공!!  (1) 2008.09.16

+ Recent posts