Newbie: Can't use WinAPI because included twice

Sorry for this lame question, but I've spent hours trying to solve this ridiculous problem. I'm trying to use the Windows API GetGUIThreadInfo, but because (I believe) it is declared twice (in winable.h and winuser.h, which I believe are implicitly included) I cannot use it. I get an identifier not found error. What do I do so I can use GetGUIThreadInfo

I haven't used C++ for a long time, and I'm not sure if I ever encountered this problem before. Please help. TIA


Answer this question

Newbie: Can't use WinAPI because included twice

  • Jason Hamlin

    Apparently the problem is that both winable.h and winuser.h declare the method, and they are both included by Windows.h. Thanks to alanfo on gotdotnet for that. Anyone know of a workaround

  • Rob-Nick

    It is being includes, as I said before, I believe implicitly in winable.h and winuser.h, and I also have windows.h included. When I try to see the definition, VS directs me to winable.h and winuser.h. I am baffled by this.

  • MichaelEber

    Try preprocessing the file in questions to see if it includes the definition of the method. Use the compiler option /P to preprocess the file.

    Thanks,
    Ayman Shoukry
    VC++ Team


  • Rof

    Problem fixed! Seems that the problem was in the definitions
    #define WINVER 0x04
    #define _WIN32_WINNT 0x04
    in the program's main header file. Should know better by now than to blame the language and MS. 0x0501 seems to work. Ah!

  • SysDev

    If you are not finding the API that means you are not including any of the headers. Make sure you are including windows.h.

    Thanks,
    Ayman Shoukry
    VC++ Team


  • RussellE

    Yep I tried using GetGUIThreadInfo in a new project including only windows.h, and it worked. Something in my other project must be creating the conflict.
  • Octagonal

    If I use #define _WINABLE_ at the beginning of the source, wouldn't that prevent winable.h from being included I tried, but it is still not working.

  • Newbie: Can't use WinAPI because included twice