Menu

problem with winuser.h

2005-03-04
2012-09-26
  • Nobody/Anonymous

    winuser.h has those lines:

    if (_WIN32_WINNT >= 0x0500)

    WINUSERAPI BOOL WINAPI EndTask(HWND,BOOL,BOOL);

    endif

    now call me a n00b, but why does it has that fucking IF?
    took me a couple of minutes to track down the problem, i ended up with adding // before the if and the end if...
    the function works perfectly BTW, even if i dont qualify to that IF statement...

     
    • Nobody/Anonymous

      No need to become vulgar about it!

       
    • Marek Januszewski

      try asking that question on mingw's win32 api forum. if this going to be a bug, PLEASE post a bug report to the mingw project. you'll make everyone's life a little easier

       
    • Nobody/Anonymous

      The reason the #if is there is to only allow this function if you have defined that you are using Windows 2000 or better.

      The function EndTask() is not available in Win9x or NT 4.0 or NT 3.5.

      So using the function makes your app incompatible with those platforms. So, you should make sure your app tests the OS it is running on and exits if it is not Windows 2000 or better.

      There are loads of functions that are guarded in a similar way. When new functions are introduced in newer OSes, they get guarded the same way. This means that the plain jane <windows.h> can be used to build applications for all platforms (going back to 95). If you need to target a specific platform and break compatibility with earlier versions of Windows, then you, the programmer, are expected to inform the compiler.

      rr

       
    • Nobody/Anonymous

      now here's the problem, i AM RUNNING WINDOWS XP!

      i'm running windows XP SP2.
      yet that i still dont pass that IF...
      so my guess is that there is a bug!
      anyway you mind link me to mingw project? i have no idea what it is :)

       
      • Wayne Keen

        Wayne Keen - 2005-03-04

        Gee, if I wanted to find out about something, the first things I would do would be to pull up Yahoo or Google, and type in

        mingw

        If so, you would have found:

        http://www.mingw.org/

        Which also would have been a pretty good guess.

        The first paragraph on the web page answers your top level question about what MinGW is:

        "MinGW: A collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU toolsets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs."

        Wayne

         
      • Marek Januszewski

         
      • Nobody/Anonymous

        The problem is not the OS you are running on, the problem is the directives you pass to the compiler when compiling the code.

        I would assume that the following would resolve your problem without requiring you to hack the source: create a new header file called ... windows_xp.h, let's say, inside of which you will put:

        ifndef _my_windows_xp___h

        idefine _my_windows_xp___h

        define _WIN32_WINNT 0x0500

        include <windows.h>

        endif

        This is exactly what the MS wizard does when it creates the afx.f files in devstudio (actually, it includes a bunch more stuff, but that is irrelevant to this discussion).

        Now, instead of #include <windows.h> you would use #include "windows_xp.h" (the same reason DevStudio wizard generated files #include "afx.h").

        Now, you have told the compiler that you want to compile for Windows 2000 and better.

        I think there is also a way to pass a define parameter on the command line to the compiler, so it could be part of the makefile - maybe someone else can answer that.

        And no, this is not a bug. It is the way the header files are structured. The ones from Microsoft are structured the same way. They only reveal the basic Win95 functions, structures, constants, etc.

        If you want to access functions, structures, constants, etc that were added in later versions of Windows, then you have to #define the OS variable correctly. I believe you can do this in the compiler options page (but I haven't got dev-cpp here, so I can't check).

        mingw can be found here: www.mingw.org

        rr

         
    • Nobody/Anonymous

      yes
      so you're saying it wont work on windows 95 and 98 (and Me)...
      oh well

      not a bug after all
      thanks for the help

       
    • Nobody/Anonymous

      sorry about the F word, didn't mean it to come out like that...
      just wondering why the IF is there...
      i mean, i kept checking at MSDN site to make sure i used the right function and that i included the right files...

       
    • Nobody/Anonymous

      ok, thanks for the reply :)
      at last, an high level replied

      althu i would guess Dev C++ would auto define that for me... i mean it's pretty easy to check if i'm with windows XP or not...
      So it might be a bug after all...

      thanks anyway

       
      • Nobody/Anonymous

        "althu i would guess Dev C++ would auto define that for me... i mean it's pretty easy to check if i'm with windows XP or not...
        So it might be a bug after all..."

        I get nervous when tools start assuming options for me.

        Even if you are developing on XP, your intended target may not be XP. It may be all windows platforms. When I used to develop for Windows, we did our development on NT 4.0 (since it was more satable than 95), but our software had to be able to run on 95 and NT 4.0.

        rr

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.