Article View: borland.public.cppbuilder.nativeapi
Article #11311Re: Loaded DLL function won't work
From: Ed Mulroy [TeamB]
Date: Wed, 18 Feb 2004 21:25
Date: Wed, 18 Feb 2004 21:25
57 lines
2598 bytes
2598 bytes
See if this works out better for you:
------------
HANDLE Lib = LoadLibrary("NYSiteP.dll");
int (*__stdcall Proc)(szRunTypes, char*&);
if (Lib != NULL)
{
// either of this which I prefer
(FARPROC) Proc = GetProcAddress(Lib, "SITE");
// or this which some others prefer
Proc = (int(*__stdcall)(szRunTypes,char*&))
GetProcAddress(Lib, "SITE");
if (Proc != NULL)
{
// ----code that calls Proc----
}
FreeLibrary(Lib);
}
------------
. Ed
> peter wrote in message
> news:4033d5c9$1@newsgroups.borland.com...
>
> I am loading a function from a DLL called 'NYSiteP' at run-time.
> The prototype is:
>
> __declspec(dllexport)int __stdcall SITE ( char *Test, char *data)
>
> I use LoadLibrary to load it, which executes fine and finds the
> DLL without a hitch. However, it will not let me compile with the
> correct amount of parameters. For instance, here is some code:
>
>
> Lib = LoadLibrary("NYSiteP");
>
> if (Lib != NULL)
> {
> Proc = (MYPROC) GetProcAddress(Lib, "SITE");
>
> if (NULL != Proc){
> (Proc) ( (char *)&rntyptable);
> (Proc) ( (char *)&flformattable) ;
> }//end if
>
> this code compiles fine, but it does not have the right amount of
> parameters. It passes this parameter to the 'Test' variable in
> the SITE function. If I try to compile with this:
>
> (Proc) (szRunTypes, (char *)&rntyptable);
>
> which is how it ought to be, I get an 'extra parameter in call'
> error. Does anyone know how I can remedy this? thanks
Technical Details
Message-ID:
<4033d84d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4033d5c9$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5a8f68731742a0dc,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-18 13:40:42 PST From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.nativeapi References: <4033d5c9$1@newsgroups.borland.com> Subject: Re: Loaded DLL function won't work Date: Wed, 18 Feb 2004 16:25:13 -0500 Lines: 60 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: <4033d84d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1077139533 24.74.175.102 (18 Feb 2004 13:25:33 -0800) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail