Solved

using CreateWaitableTimer in Non-MFC Code?

Posted on 1998-01-15
5
651 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:gunn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 70 total points
ID: 1178372
CreateWaitableTimer is a Win32 API function (NT only by the way) and it's defined in winbase.h.  If you include that as well as windows.h, you should have all you need.  Be sure to link with kernel32.lib.  This function is not MFC but certainly requires a 32-bit compiler.  You didn't mention your environment, if you're not using a compiler which supports NT, then you can't use this function.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1178373
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???


0
 

Author Comment

by:gunn
ID: 1178374
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.
0
 

Author Comment

by:gunn
ID: 1178375
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.


0
 

Expert Comment

by:bhovan
ID: 1178376
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.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question