Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
641 views
in Technique[技术] by (71.8m points)

winapi - Referencing GUIDs

I'm trying to capture an event and reference a GUID to see which event it is. The code is below:

DWORD WINAPI AvisionEventProc(LPVOID lpParam){
    //HANDLE hEvent = * (HANDLE *) lpParam;   // This thread's read event
    STINOTIFY pStiNotify;

    if (debug){
        wprintf(L"Avision Event
");
    }
    while(true){
        WaitForSingleObject(hAvisionEvent, INFINITE);
        wprintf(L"Event");
        pStiDevice->GetLastNotificationData(&pStiNotify);
        if (pStiNotify.guidNotificationCode == GUID_STIUserDefined1){
            wprintf(L"User defined 1");
        }else if (pStiNotify.guidNotificationCode == GUID_STIUserDefined2){
            wprintf(L"User defined 2");
        }else if (pStiNotify.guidNotificationCode == GUID_STIUserDefined3){
            wprintf(L"User defined 3");
        }

        ResetEvent(hAvisionEvent);
    }
    return 1;
}

This compiles just fine but I get the errors below when linking:

1>sti.obj : error LNK2001: unresolved external symbol _GUID_STIUserDefined3
1>sti.obj : error LNK2001: unresolved external symbol _GUID_STIUserDefined2
1>sti.obj : error LNK2001: unresolved external symbol _GUID_STIUserDefined1

The strange thing is that sti.h is linked in as I am pulling other constants from it. I did notice by the GUID decleration the following:

#if defined( _WIN32 ) && !defined( _NO_COM)

/*
 * Class IID's
 */

// B323F8E0-2E68-11D0-90EA-00AA0060F86C
DEFINE_GUID(CLSID_Sti, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6C);

/*
 * Interface IID's
 */

// {641BD880-2DC8-11D0-90EA-00AA0060F86C}
DEFINE_GUID(IID_IStillImageW, 0x641BD880L, 0x2DC8, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6C);

<snip>

/*
 * Standard event GUIDs
 */

// {740D9EE6-70F1-11d1-AD10-00A02438AD48}
DEFINE_GUID(GUID_DeviceArrivedLaunch, 0x740d9ee6, 0x70f1, 0x11d1, 0xad, 0x10, 0x0, 0xa0, 0x24, 0x38, 0xad, 0x48);

<snip>

#endif

Does the "if defined" line stop the GUIDs being referenced (I am writing a win32 console app) or is there something more fundamental I have wrong here to do with a lack of understanding on GUIDs?

Thanks, in advance for your help.

Cheers,

Neil

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

#include <initguid.h>should be added. That will help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...