Article View: borland.public.cppbuilder.nativeapi
Article #8183Re: Is it possible to use Wininet functions WITHOUT LINKING the Wininet.lib ??
From: Remy Lebeau (TeamB)
Date: Sat, 13 Nov 2004 05:18
Date: Sat, 13 Nov 2004 05:18
88 lines
3557 bytes
3557 bytes
"Oren Halvani" <Spam@Me-Please.com> wrote in message
news:4195658a@newsgroups.borland.com...
> OK..what do you think of this usage:
I think you need to cache your InternetGetConnectedStatePtr pointer so that
you are not retreiving it every time you want to call it. Try this instead:
#include <WININET.h>
typedef BOOL WINAPI (*LPFN_IGCS)(DWORD*, DWORD);
HMODULE wininet_hand = NULL;
LPFN_IGCS InternetGetConnectedStatePtr = NULL;
__fastcall TfrmMainUnit::TfrmMainUnit(TComponent* Owner)
: TForm(Owner)
{
wininet_hand = LoadLibrary("WININET.DLL");
}
__fastcall TfrmMainUnit::~TfrmMainUnit()
{
if( wininet_hand )
FreeLibrary(wininet_hand);
}
void __fastcall TfrmMainUnit::Button1Click(TObject *Sender)
{
if( wininet_hand )
{
if( InternetGetConnectedStatePtr == NULL )
InternetGetConnectedStatePtr = (LPFN_IGCS)
GetProcAddress(wininet_hand, "InternetGetConnectedState");
if( InternetGetConnectedStatePtr )
{
//...
}
else ShowMessage("InternetGetConnectedState function not
found");
}
else ShowMessage("Unable to load WinInet.DLL");
}
Even better, retreive the function pointer in the constructor instead:
#include <WININET.h>
typedef BOOL WINAPI (*LPFN_IGCS)(DWORD*, DWORD);
HMODULE wininet_hand = NULL;
LPFN_IGCS InternetGetConnectedStatePtr = NULL;
__fastcall TfrmMainUnit::TfrmMainUnit(TComponent* Owner)
: TForm(Owner)
{
wininet_hand = LoadLibrary("WININET.DLL");
if( wininet_hand )
{
InternetGetConnectedStatePtr = (LPFN_IGCS)
GetProcAddress(wininet_hand, "InternetGetConnectedState");
if( InternetGetConnectedStatePtr == NULL )
ShowMessage("InternetGetConnectedState function not found");
//...
}
else ShowMessage("Unable to load WinInet.DLL");
}
__fastcall TfrmMainUnit::~TfrmMainUnit()
{
if( wininet_hand )
FreeLibrary(wininet_hand);
}
void __fastcall TfrmMainUnit::Button1Click(TObject *Sender)
{
if( InternetGetConnectedStatePtr )
{
//...
}
}
Gambit
Technical Details
Message-ID:
<419598ac$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<419508ed$1@newsgroups.borland.com> <419516cd$1@newsgroups.borland.com> <41955b2e$1@newsgroups.borland.com> <41955ff6@newsgroups.borland.com> <4195658a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7fd10020e90983c X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <419508ed$1@newsgroups.borland.com> <419516cd$1@newsgroups.borland.com> <41955b2e$1@newsgroups.borland.com> <41955ff6@newsgroups.borland.com> <4195658a@newsgroups.borland.com> Subject: Re: Is it possible to use Wininet functions WITHOUT LINKING the Wininet.lib ?? Date: Fri, 12 Nov 2004 21:18:07 -0800 Lines: 90 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: 68.69.17.41 Message-ID: <419598ac$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1100322988 68.69.17.41 (12 Nov 2004 21:16:28 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail