Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error building a dll. 1

Status
Not open for further replies.

Jaroslaw

Programmer
Oct 15, 2002
10
CA
Hi all,

I'm trying to create my first C++ dll for use with my VB program.
It is probably an easy one for you guys. I cannot build my project because of the following:

I'm getting this build error:
'SetupDiGetClassDevsA': cannot convert parameter 1 from 'const struct_GUID *' to 'struct_GUID *'

On this line:
// get a list of all devices of class 'GUID_DEVCLASS_NET'
hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT);

Can anyone help me please?

Thanks,
Jaroslaw

 
I think you have found a bug in the documentation or the prototypes in setupapi.h.
It should be a pointer to a const GUID according to the documentation, but the prototypes disagree.

This is a workaround :
GUID myguid = GUID_DEVCLASS_NET;
HDEVINFO hdi = SetupDiGetClassDevs(&myguid, NULL, NULL, DIGCF_PRESENT);
/JOlesen
 
Thanks JOLESEN,

Your workaround works great.
My project compiles fine now, but I still get some errors. I get the following linker error when building:

Compiling...
NIC Control.cpp
Linking...
NIC Control.obj : error LNK2001: unresolved external symbol __imp__SetupDiCallClassInstaller@12
NIC Control.obj : error LNK2001: unresolved external symbol __imp__SetupDiSetClassInstallParamsA@16
NIC Control.obj : error LNK2001: unresolved external symbol __imp__SetupDiEnumDeviceInfo@12
NIC Control.obj : error LNK2001: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4
NIC Control.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetClassDevsA@16
Debug/Control Network.dll : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.

Control Network.dll - 6 error(s), 0 warning(s)

Is my compiler missing something? For example, a required library for these functions. If so how would I reference it to my project in C++? I did "include" the following in my header file:
#include <windows.h>
#include <setupapi.h>
#include <devguid.h>
#include <setupapi.h>

Please bear with me, I'm a newbie as you can tell :)
 
You need to add library setupapi.lib to the project.

You have 2 (at least) ways to do this :
1) Use a #pragma comment(lib, &quot;setupapi.lib&quot;) // Place it somewhere in a source-file.
2) Go to the project settings, Tab 'Link' field &quot;Object/Library modules&quot; and add setupapi.lib to the list.
/JOlesen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top