🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Correction: GetProcAddress return type

#12079
From: Muzzy
Date: Thu, 25 Dec 2003 06:19
73 lines
2698 bytes
Muzzy wrote:

> Hi,
> 
> I hope someone can help:
> 
> I have a dll which exports:
> 
> extern "C" __declspec(dllexport) bool VPNStart();
> 
> I also have an app, which wants to call the dll and get the address of 
> "VPNStart":
> 
> 
> typedef bool (HVPNSTART)(void);
> 
> bool VNCStart(void)
> {
>   HINSTANCE hLib = LoadLibrary("VPNCHK32.DLL");
>   if (hLib == NULL) {
>     MessageBox(0, "Unable to Load VPNCHK32.DLL", "Error", MB_OK);
>     return false;
>   }
>   HVPNSTART* vs = (HVPNSTART*)GetProcAddress(hLib, "_VPNStart");
>   if (vs == NULL) {
>     MessageBox(0, "Failed calling VPNStart", "Error", MB_OK);
>     FreeLibrary(hLib);
>     return false;
>   }
>   MessageBox(0, "VPNStart Loaded!", "SUCCESS", MB_OK);
> 
>   FreeLibrary(hLib);
>   return true;
> }
> 
> 
> It doesn't work - vs gets NULL value, although "_VPNStart" shows when i 
> dump the DLL.
> My only thought that i messed somewhere with typecasts in calling 
> function, incorrectly defined HVPNSTART...
> 
> 
> Any ideas?
> 
> Thank you,
> Andrey
> 


typedef bool* (*HVPNSTART)(void);

bool VNCStart(void)
{
   HINSTANCE hLib = LoadLibrary("VPNCHK32.DLL");
   if (hLib == NULL) {
     MessageBox(0, "Unable to Load VPNCHK32.DLL", "Error", MB_OK);
     return false;
   }
   HVPNSTART* vs = (HVPNSTART*)GetProcAddress(hLib, "_VPNStart");
   if (vs == NULL) {
     MessageBox(0, "Failed calling VPNStart", "Error", MB_OK);
     FreeLibrary(hLib);
     return false;
   }
   MessageBox(0, "VPNStart Loaded!", "SUCCESS", MB_OK);

   bool result = vs();

   FreeLibrary(hLib);
   return result;
}

Now compiler says that vs is non-function and i can't call it?
Technical Details
Message-ID: <3fea818c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fea7f6e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3d934f741828d59c
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-24 22:39:02 PST
Date: Thu, 25 Dec 2003 01:19:46 -0500
From: Muzzy <leyandrew@yahoo.com>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Correction:  GetProcAddress return type
References: <3fea7f6e$1@newsgroups.borland.com>
In-Reply-To: <3fea7f6e$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.91.233.60
Message-ID: <3fea818c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1072333196 24.91.233.60 (24 Dec 2003 22:19:56 -0700)
Lines: 74
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail