🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Run Time Dynamic linking

#11207
From: Ed Mulroy [TeamB]
Date: Thu, 19 Feb 2004 18:44
35 lines
2094 bytes
Peter,

It is an alternative way of doing things.

The type returned by GetProcAddress is FARPROC.

Consider this:

  int __stdcall (*func_ptr)(char *, char *) func_addr;

  // cast the return value to the complex type of the function pointer
  func_addr =
     (int __stdcall (*func_ptr)(char *, char *))
     GetProcAddress(module_handle, "FunctionName");

versus this:

  int __stdcall (*func_ptr)(char *, char *) func_addr;

  // cast the function pointer to the simple type returned by GetProcAddress
  (FARPROC) func_addr =
     GetProcAddress(module_handle, "FunctionName");

There is NO type-safety in the use of GetProcAddress because it will return
the address of whatever symbol is associated with the character string you
request (even the address of a data item had one been exported).  Therefore
I prefer the simpler method of casting on the left.

.  Ed

> peter wrote in message
> news:4034e949$1@newsgroups.borland.com...
>
> ... casting 'Proc' to (FARPROC) on the GetProcAddress call.
> I still don't get what that accomplishes ...
Technical Details
Message-ID: <40350424$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4034d732$1@newsgroups.borland.com> <4034e538$1@newsgroups.borland.com> <4034e949$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c9838237a73aa85e
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-19 11:10:27 PST
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4034d732$1@newsgroups.borland.com> <4034e538$1@newsgroups.borland.com> <4034e949$1@newsgroups.borland.com>
Subject: Re: Run Time Dynamic linking
Date: Thu, 19 Feb 2004 13:44:30 -0500
Lines: 37
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.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <40350424$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1077216292 24.74.175.102 (19 Feb 2004 10:44:52 -0800)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail