🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16601

Re: FlashWindowEx, USER32.DLL on WinNT

#16601
From: Remy Lebeau (TeamB)
Date: Thu, 08 May 2003 16:52
50 lines
2678 bytes
"Justin Ridge" <spamstop@terriertech.com> wrote in message
news:3eba5f0e$2@newsgroups.borland.com...

> I understand that FlashWindowEx is not supported on WinNT

Correct.

> and my code checks for its availability (see below).

No, it is not.  Even though you are testing the OS version, you are still
statically linking to the function itself without testing for the specific
availability of the function itself.  Which is evident by the fact that you
got the error in the first place.

> However, this error occurs IMMEDIATELY when I start the app

Correct, because you are still static linking to a function that doesn't
exist on that machine, so the OS loader fails to load the process
immediately, before it ever gets a chance to execute its first instruction.

Just because you are using a conditional statement to control the *run-time*
behavior of the code does not negate that you are still linking to both
functions at *compile-time*.

> How can I get the app to start on WinNT?

You need to use GetProcAddress() to dynamically obtain the actual pointer to
FlashWindowEx() at runtime, instead of linking to it at compile-time.  Then
you don't even need to do OS version checking at all - if the function is
available on a given machine, you will have a pointer to it.  Otherwise, you
will have a NULL pointer and can call FlashWindow() instead:

    // Is FlashWindowEx available?

    typedef BOOL WINAPI PFWEX(PFLASHWINFO);

    PFWEX lpFlashWindowEx = (PFWEX)
GetProcAddress(GetModuleHandle("USER32"), "FlashWindowEx");

    if( lpFlashWindowEx )
    {
        //...
        lpFlashWindowEx(&info);
    }
    else
        FlashWindow(Application->Handle, true);


Gambit
Technical Details
Message-ID: <3eba8af2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3eba5f0e$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2866fa51de16e98a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-08 10:00:36 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3eba5f0e$2@newsgroups.borland.com>
Subject: Re: FlashWindowEx, USER32.DLL on WinNT
Date: Thu, 8 May 2003 09:52:46 -0700
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3eba8af2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1052412658 207.175.226.26 (8 May 2003 09:50:58 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail