Source code of Windows XP (NT5)
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.

63 lines
1.1 KiB

  1. #include "devinfo.h"
  2. #include "vol.h"
  3. #include "dtct.h"
  4. #include "dtctreg.h"
  5. #include "svcsync.h"
  6. #include "cmmn.h"
  7. #include "misc.h"
  8. #include "tfids.h"
  9. #include "dbg.h"
  10. #define ARRAYSIZE(a) (sizeof((a))/sizeof((a)[0]))
  11. STDMETHODIMP CHWDeviceImpl::Init(LPCWSTR pszDeviceID)
  12. {
  13. HRESULT hr;
  14. if (!_fInited)
  15. {
  16. if (pszDeviceID && *pszDeviceID)
  17. {
  18. hr = DupString(pszDeviceID, &_pszDeviceID);
  19. if (SUCCEEDED(hr))
  20. {
  21. _fInited = TRUE;
  22. }
  23. }
  24. else
  25. {
  26. hr = E_INVALIDARG;
  27. }
  28. }
  29. else
  30. {
  31. // Cannot reinit
  32. hr = E_FAIL;
  33. }
  34. return hr;
  35. }
  36. STDMETHODIMP CHWDeviceImpl::AutoplayHandler(LPCWSTR pszEventType,
  37. LPCWSTR pszHandler)
  38. {
  39. return _ExecuteHandler(_pszDeviceID, pszEventType,
  40. pszHandler);
  41. }
  42. CHWDeviceImpl::CHWDeviceImpl() : _pszDeviceID(NULL), _fInited(FALSE)
  43. {
  44. _CompleteShellHWDetectionInitialization();
  45. }
  46. CHWDeviceImpl::~CHWDeviceImpl()
  47. {
  48. if (_pszDeviceID)
  49. {
  50. LocalFree(_pszDeviceID);
  51. }
  52. }