🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How do I translate this Delphi code to BCB5?

#970
From: Remy Lebeau (TeamB)
Date: Thu, 22 Nov 2007 20:37
31 lines
1882 bytes
"Mark Jacobs" <http://www.jacobsm.com/mjmsg.htm?BorlandNG> wrote in message
news:474598cd@newsgroups.borland.com...

> How do I translate this Delphi code to BCB5?

RegisterServiceProcess() is not declared in any header file, and is not
linked to by kernel32.lib, so you have to use dynamic loading via
GetProcAddress() to use it, ie:

    typedef DWORD (WINAPI *LPFN_RSP)(DWORD, DWORD);
    LPFN_RSP lpRegisterServiceProcess = NULL;

    __fastcall TForm1::TForm1(TComponent *Owner)
        : TForm(Owner)
    {
        lpRegisterServiceProcess = (LPFN_RSP)
GetProcAddress(GetModuleHandle("KERNEL32"), "RegisterServiceProcess");

        if( lpRegisterServiceProcess )
            lpRegisterServiceProcess(GetCurrentProcessId(), 1);
    }

    __fastcall TForm1::~TForm1()
    {
        if( lpRegisterServiceProcess )
            lpRegisterServiceProcess(GetCurrentProcessId(), 0);
    }


Gambit
Technical Details
Message-ID: <4745e86c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <474598cd@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d35c7f2f5f6b99bd
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <474598cd@newsgroups.borland.com>
Subject: Re: How do I translate this Delphi code to BCB5?
Date: Thu, 22 Nov 2007 12:37:58 -0800
Lines: 33
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: 75.83.29.61
Message-ID: <4745e86c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195763820 75.83.29.61 (22 Nov 2007 12:37:00 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail