🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Import functions from gll by index.

#17127
From: user
Date: Mon, 07 Apr 2003 04:28
47 lines
2272 bytes
Mariusz Grecki wrote:
> It is a shame, but I can not import a function from
> kernel32.dll by index. Using the name it is possible
> but by index GetProcAddress fails returning NULL.
> What I am doing wrong?
> 
> Example:
> =================================
> HINSTANCE hlk32;
> FARPROC LoadLibrary16;
> FARPROC FreeLibrary16;
> FARPROC GetProcAddress16;
> FARPROC BeepA, BeepB;
> 
> .............
>    hlk32=LoadLibrary("kernel32");
> 
>    BeepB=GetProcAddress(hlk32, (LPSTR)10);
>    BeepA=GetProcAddress(hlk32, "Beep");
> ...........
>    FreeLibrary(hlk32);
> ================================
> BeepA is OK.
> BeepB is NULL!
> 
> Any comments?

The ordinal for Beep is 13 in my KERNEL32.DLL. I was able to get the 
following code to work as expected (both BeepA and BeepB had the same 
value):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
     typedef BOOL (WINAPI * BeepProc)(DWORD, DWORD);
     HINSTANCE hlk32;
     BeepProc BeepA, BeepB;

     hlk32=LoadLibrary("kernel32");

     BeepB=(BeepProc)GetProcAddress(hlk32, MAKEINTRESOURCE(13));
     BeepA=(BeepProc)GetProcAddress(hlk32, "Beep");

     BeepB(100, 100);
     BeepA(200, 100);

     FreeLibrary(hlk32);
}
Technical Details
Message-ID: <3E90FE56.8020201@domain.invalid>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3e8165eb@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3166b65da596fd46
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-04-06 21:35:49 PST
Message-ID: <3E90FE56.8020201@domain.invalid>
Date: Mon, 07 Apr 2003 00:28:06 -0400
From:  user@domain.invalid
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Import functions from gll by index.
References: <3e8165eb@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 68.162.165.211
X-Trace: newsgroups.borland.com 1049689705 68.162.165.211 (6 Apr 2003 21:28:25 -0800)
Lines: 48
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail