Getting Error LNK2019 unresolved external symbol SetupDiGetDeviceInstanceIdW() on Windows program, works on Console program

Greg Wilson-Lindberg 126 Reputation points
2022-12-01T19:14:14.683+00:00

I have a piece of code that searches through USB connected serial devices looking for a specific VID & PID. I have debugged the code on a couple of console applications (SubSystem Console), and it is working correctly.

I have now moved the code into a windows form application (SubSystem Windows), and I am getting a number of the above errors. I have added the SetupAPI.lib to the linker "Additional Dependencies" in the Properties, but I still get the error.

Is there some problem with trying to use these SetupDI* calls from a "Windows" program as opposed to a "Console" application?

Right now I have the calls in the main() function, so they are not being called from inside managed code. But maybe I'm running into some other problem because it is a Window app and not a Console app.

Regards,
Greg

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,821 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,519 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. Greg Wilson-Lindberg 126 Reputation points
    2022-12-05T16:46:04.59+00:00

    @RLWA32 , you called it correctly. I'm new to using the (modern) Visual Studio, and am (obviously) not good at making sure that the properties that I'm selecting are for the build type that I have selected.

    Thanks for the clue bat,

    Greg