3

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 ?

4

1 に答える 1

3

私はWindows DDKを手元に持っていないので確認できませんが、別のフォーラムのユーザーがbeforeを含めることで動作すると報告しているinitguid.hntddstor.hため、次のように動作する可能性があります:

#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
于 2012-05-16T13:48:41.780 に答える