Link to home
Start Free TrialLog in
Avatar of gunn
gunn

asked on

using CreateWaitableTimer in Non-MFC Code?

I am trying to include the function CreateWaitableTimer() and its associated functions into a 'C' program, that otherwise doesn't have anything to do with Windows or MFC.

It says to #include <winbase.h>. I did this. I then tried to compile it but got errors about DWORD. I found the definition of DWORD in windef.h, but then got errors in winnt.h about "winnt.h(2057) syntax error: identifier 'PCONTEXT' ". Well, PCONTEXT is defined above that in the same file.hhmmmmmm.

Anyway, it looks like I could spend days adding #include files into my file just to use this function, and getting them in the proper order. Can anyone help me use this function? What do I need to #include? Then comes the question of what libs I need to link with.....

Thanks,

Tom
ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tommy Hui
Tommy Hui

thanks for the quick response. Your answer is correct in that including windows.h did the trick (found that out shortly after the question...hehe).

Anyway, forgot to mention about the environment. I'm running WindowsNT4.0 w/ Service Pack 3, and the MSVisualC++ 5.0 compiler.

Heres my new problem with this function: I'm getting a 'CreateWaitableTimer' undefined: assuming extern returning int'
message. I went through winbase.h and found that there is a preprocessor definition #if( _WIN32_WINNT >= 0x0400 ) around the  prototype of the functions I need.  It seems to be not true as I would think.  Why is this not true in my case???


Avatar of gunn

ASKER

man, you guys are fast in your responses. before I could finish typing out the comment above about the problem, thui had answered my question!! It works fine now...thanks guys.
Avatar of gunn

ASKER

THE FOLLOWING IS FROM MSDN
Article Id : Q167799
Last Reviewed: March 31, 1998
Section 3 - Header File Conventions

In the header files, information guarded by


    #if _WIN32_WINNT >= 0x0400

is implemented only in Windows NT version 4.0 and later.
It is not implemented in Windows 95.
This precompiler guard allows you to do compile- time checking for platform differences.
The value of _WIN32_WINNT is set in WIN32.MAK, depending on the platform you choose to target.
By default, WIN32.MAK now sets the TARGETOS to WINNT and the APPVER to 4.0.
As a result, by default, _WIN32_WINNT is now defined as 0x0400.

If you are building an application to run on Windows 95 and you want compile-time notification of compatibility issues,
set TARGETOS=BOTH in your makefile.
When TARGETOS is defined as BOTH, _WIN32_WINNT is not defined for the precompiler,
and the only information parsed at compile time will be applicable to both Windows 95 and Windows NT.

If you do not include WIN32.MAK in your makefile,
you need to explicitly define _WIN32_WINNT as 0x0400 to get some of the new Windows NT 4.0- specific material from the header files.

There are several API sets present in Windows 95,
OEM Service Release 2 that are still guarded by (_WIN32_WINNT >= 0x0400),
e.g. the Cryptography API. If you are writing an application specifically for Windows 95,
OEM Service Release 2, and you want the header files to provide compile time access to these APIs,
it is necessary to define _WIN32_WINNT as 0x0400.
Notice that an application that uses these technologies will not run correctly on the retail release of Windows 95.
The vast majority of application programs that are expected to run on Windows 95 should be built without defining _WIN32_WINNT.


THE FOLLOWING IS FROM MSDN
Article Id : Q167799
Last Reviewed: March 31, 1998
Section 3 - Header File Conventions

In the header files, information guarded by


    #if _WIN32_WINNT >= 0x0400

is implemented only in Windows NT version 4.0 and later.
It is not implemented in Windows 95.
This precompiler guard allows you to do compile- time checking for platform differences.
The value of _WIN32_WINNT is set in WIN32.MAK, depending on the platform you choose to target.
By default, WIN32.MAK now sets the TARGETOS to WINNT and the APPVER to 4.0.
As a result, by default, _WIN32_WINNT is now defined as 0x0400.

If you are building an application to run on Windows 95 and you want compile-time notification of compatibility issues,
set TARGETOS=BOTH in your makefile.
When TARGETOS is defined as BOTH, _WIN32_WINNT is not defined for the precompiler,
and the only information parsed at compile time will be applicable to both Windows 95 and Windows NT.

If you do not include WIN32.MAK in your makefile,
you need to explicitly define _WIN32_WINNT as 0x0400 to get some of the new Windows NT 4.0- specific material from the header files.

There are several API sets present in Windows 95,
OEM Service Release 2 that are still guarded by (_WIN32_WINNT >= 0x0400),
e.g. the Cryptography API. If you are writing an application specifically for Windows 95,
OEM Service Release 2, and you want the header files to provide compile time access to these APIs,
it is necessary to define _WIN32_WINNT as 0x0400.
Notice that an application that uses these technologies will not run correctly on the retail release of Windows 95.
The vast majority of application programs that are expected to run on Windows 95 should be built without defining _WIN32_WINNT.