Masum
Masum

Reputation: 439

Device detection connected to PC using C++

How can I detect the connected devices into a Computer using C++? I can use windows programming facility, but .Net functionality is not allowed.

Thanks in advance.

Upvotes: 0

Views: 2303

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283634

The SetupDi* (device manager) APIs can be called from C++.

If you want information about hot-plugged devices, you'll want to combine this with Alex's suggestion of WM_DEVICECHANGE, which tells you when to call SetupDi* again.

Upvotes: 1

Alex F
Alex F

Reputation: 43311

Try to handle WM_DEVICECHANGE message. When wParam = DBT_DEVICEARRIVAL, new device is detected.

Upvotes: 1

Related Questions