Thread: Cannot find Function: QueueUserWorkItem

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    12

    Cannot find Function: QueueUserWorkItem

    Hello,

    I am using Dev C++ and am wondering where the hell the function QueueUserWorkItem is located. I used API Viewer and found the function is in kernel32.dll but am wondering what .lib file would I need to add or if its some header file I'm missing.

    Any help is appreciated.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Most things on MSDN tell you the requirements
    http://msdn.microsoft.com/library/de...erworkitem.asp
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    12
    Quote Originally Posted by Salem
    Most things on MSDN tell you the requirements
    http://msdn.microsoft.com/library/de...erworkitem.asp
    Tried linking the libkernel32.a file and including windows.h but doesn't work.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Have you got:
    Code:
    #define _WIN32_WINNT 0x0500
    above all your #includes?

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    12
    Quote Originally Posted by anonytmouse
    Have you got:
    Code:
    #define _WIN32_WINNT 0x0500
    above all your #includes?
    Never heard of using that but just tried putting it above the includes and no luck.

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    What is the exact error message you are getting? The function is either missing from the header file, missing from the import library, or you have mistyped it in your code.

    A quick search suggests that QueueUserWorkItem was added to the MinGW headers in July, 2005 and only made its way into Dev-C++ later. So you need to either get the latest version of Dev-C++, or update MinGW as this tutorial shows.

    Alternatively, you can probably just paste the prototype into your code:
    Code:
    BOOL
    WINAPI
    QueueUserWorkItem(
        LPTHREAD_START_ROUTINE Function,
        PVOID Context,
        ULONG Flags
        );

  7. #7
    Registered User
    Join Date
    Aug 2006
    Posts
    12
    Quote Originally Posted by anonytmouse
    What is the exact error message you are getting? The function is either missing from the header file, missing from the import library, or you have mistyped it in your code.

    A quick search suggests that QueueUserWorkItem was added to the MinGW headers in July, 2005 and only made its way into Dev-C++ later. So you need to either get the latest version of Dev-C++, or update MinGW as this tutorial shows.

    Alternatively, you can probably just paste the prototype into your code:
    Code:
    BOOL
    WINAPI
    QueueUserWorkItem(
        LPTHREAD_START_ROUTINE Function,
        PVOID Context,
        ULONG Flags
        );
    It said the function could not be found. When adding the prototype into the code then it says undefined reference to the function. I am using 4.9.9.2 by the way. I'm guessing the libkernel32.a needs file needs updating?

  8. #8
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    I guess it depends on if the error message was a link-time message, or a compile time message. If it was a linker error, your lib file is at fault, and if it's a compiler error, you're missing the prototype. If linker error, and you don't want to deal with looking for a new lib file, you could use GetModuleHandle() and GetProcAddress(), and then as long as you have the correct .dll file on your system, everything will work.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM