🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: GetSystemTimes and Borland C++ Builder

#5130
From: Remy Lebeau (TeamB)
Date: Wed, 12 Oct 2005 02:37
41 lines
2334 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message
news:434c5d74@newsgroups.borland.com...

> My problem is that this function is quite new so my BCB 6
> haven't it in winbase.h and, I suppose, in Kernel32.lib.

GetSystemTimes() is only available on XP SP1, 2003 Server, and Vista
(Longhorn).  BCB6 was released years before any of them were released.

> Somebody can help me to solve the problem?

Use GetModuleHandle() and GetProcAddress() to load the function dynamically
at runtime.  For example:

    typedef BOOL (__stdcall *LPFN_GST)(LPFILETIME, LPFILETIME, LPFILETIME);

    LPFN_GST lpGetSystemTimes = (LPFN_GST)
GetProcAddress(GetModuleHandle("KERNEL32"), "GetSystemTimes");
    if( lpGetSystemTimes )
    {
        FILETIME IdleTime, KernelTime, UserTime;
        if( lpGetSystemTimes(&IdleTime, &KernelTime, &UserTime) )
        {
            // use IdleTime, KernelTime, UserTime as needed...
        }
        else
        {
            DWORD dwError = GetLastError();
            // use dwError as needed...
        }
    }

> Should I download the Platform SDK from Microsoft site?

No, because much of it is not usable with BCB as-is.  Borland usually has to
make tweaks to the PSDK in order for it to work with Borland's compiler and
then release their own copy of it with the IDE.


Gambit
Technical Details
Message-ID: <434c76ff$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <434c5d74@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,decdfd9a1b916fa8
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <434c5d74@newsgroups.borland.com>
Subject: Re: GetSystemTimes and Borland C++ Builder
Date: Tue, 11 Oct 2005 19:37:04 -0700
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <434c76ff$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1129084671 68.69.17.41 (11 Oct 2005 19:37:51 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail