Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

  1. // DevInfoSet.h: Definition of the CDevInfoSet class
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_DEVINFOSET_H__7973729E_46E1_4B31_B15E_7B702679AC64__INCLUDED_)
  5. #define AFX_DEVINFOSET_H__7973729E_46E1_4B31_B15E_7B702679AC64__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "resource.h" // main symbols
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CDevInfoSet
  12. class ATL_NO_VTABLE CDevInfoSet :
  13. public IDevInfoSet,
  14. public CComObjectRootEx<CComSingleThreadModel>
  15. {
  16. public:
  17. HDEVINFO hDevInfo;
  18. public:
  19. CDevInfoSet() {
  20. //
  21. // use NULL to indicate uninitialized vs failed to initialize
  22. //
  23. hDevInfo = NULL;
  24. }
  25. ~CDevInfoSet() {
  26. if(hDevInfo != INVALID_HANDLE_VALUE && hDevInfo != NULL) {
  27. SetupDiDestroyDeviceInfoList(hDevInfo);
  28. }
  29. }
  30. BOOL Init(HDEVINFO Handle) {
  31. hDevInfo = Handle;
  32. return TRUE;
  33. }
  34. HDEVINFO Handle() {
  35. //
  36. // initialize on demand
  37. //
  38. if(hDevInfo == NULL) {
  39. hDevInfo = SetupDiCreateDeviceInfoList(NULL,NULL);
  40. }
  41. return hDevInfo;
  42. }
  43. DECLARE_NOT_AGGREGATABLE(CDevInfoSet)
  44. DECLARE_PROTECT_FINAL_CONSTRUCT()
  45. BEGIN_COM_MAP(CDevInfoSet)
  46. COM_INTERFACE_ENTRY(IDevInfoSet)
  47. END_COM_MAP()
  48. // IDevInfoSet
  49. public:
  50. STDMETHOD(get_Handle)(/*[out, retval]*/ ULONGLONG *pVal);
  51. };
  52. #endif // !defined(AFX_DEVINFOSET_H__7973729E_46E1_4B31_B15E_7B702679AC64__INCLUDED_)