I am trying to use GUID_DEVINTERFACE_DISK
(or _FLOPPY... etc) in function SetupDiGetClassDevs
, but g++ still don't build because of an undefined reference.
I have linked to with SetupAPI and incuded nstddstor.h as requiered (http://msdn.microsoft.com/en-us/library/windows/hardware/ff545824%28v=vs.85%29.aspx).
I saw that including initguid.h may resolve the problem, but it doesn't for me.
Also, when I try affecting a GUID variable as
GUID g = GUID_DEVINTERFACE_DISK;
and if I put my mouse on GUID_DEVINTERFACE_DISK, eclipse shows me where is it defined (nstddstor.h), but after compiling, it still doesn't work.
Any solutions ?
I don't have the Windows DDK handy and so I can't verify it but a user on another forum reports that it works by including initguid.h
before ntddstor.h
, so the following might work:
#include <initguid.h>
#include <ntddstor.h>
#include <Setupapi.h>
// Code copied from:
// http://msdn.microsoft.com/en-us/library/windows/hardware/ff551069.aspx
int main(void) {
HDEVINFO hDevInfo;
hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_VOLUME,
NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
}
cl /nologo /W4 /EHsc /MD guid.cpp Setupapi.lib