Hi there, I'm working on something where I need to create a waitable timer event to be used in conjunction of winsock overlapped i/o. for some reason when i tried to set it up using CreateWaitableTimer() in VC++ (6.0), it complained that there's no such function: "error C2065: 'CreateWaitableTimer' : undeclared identifier." The code i use is as follow:
I even tried to compile the code from (here for link )MSDN and it still won't work... if someone knows the reason why this is so please let me know. Thanks in advance..
Handel waitEvents = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
Are you using an NT cored system or 9x? Waitable timers are 32 bit specific.
Both NT and 9x are 32-bit operating systems.
CreateWaitableTimer is included in Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, and Windows 98.
You'll need to download a new SDK, or load the function dynamically from kernel32.dll using GetProcAddress(). I recommend downloading a new SDK.
By 32 bit I mean genuine 32 bit, not a 16/32 bit lash up such as the 9x core. From MSDN...
Windows NT: Requires version 4.0 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
... from the CreateWaitableTimer() entry. That may have changed of course, but that is what mine says, and by the looks of the error message he is getting, that would seem to be his problem.
*** EDIT ***
The CreateWaitableTimer() documentation at the web site does, indeed, show that it can be retro fitted - my MSDN disks are out of date. However, I would still suspect that this is what his problem is.
Hm.. I'm running Windows XP... i found the declaration of the function in winbase.h.. it's there.. i'm just not able get it to compile. i also tested this on visual studio.net.. it seems to have the same problem.. one thing strange i did recongized was.. I accidentally put the source code (from above MSDN link) into a .h file? and it compiled without complaining.. i'm not sure what exactly is the problem of an NT system.. since most of my friends has XP/2000 machines i wasn't able to get a 98 system to test it on... you think u can let me know exactly how i can fix the problem?
hm.. seems like i forgot to define _WIN32_WINNT to 0x0501.. but now when i define this, i introduced a new problem.. it seems like this defintion blocks off my winsock2.h.. anyone knows why? im not very familiar with the whole win32 mechanism.. so please point me to the right direction.. thanks again 4 ur help.
>>> blocks off my winsock2.h..
Are you linking the Winsock library, (ws2_32.lib)? You need to add it to the list of libraries, Project->Settings->Link Tab, then add the library to the end of the list in the "Object/Library modules" box.
Yea, ws2_32.lib was linked.. it's just that when i define _WIN32_WINNT.. it some how blocks off winsock2.h. i'm not exactly what's the problem. :confused:
The source you cited at MSDN would not compile for me without NT 0x0400, but did afterwards, as did a call to WSAStartup().
hm... i finally got it to work.. the order of my includes makes hell of a difference..
i'm not sure why the order of my includes would have such an effect. i assume it's probably something defined in winsock2.h or windows.h. i'd love to hear the reason if anyone cares to explain. for now, im happy that it finally compiles! :D
winsock2.h isnt done very well.....it includes windows.h so you dont need to include windows.h at all