🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Is it possible to use Wininet functions WITHOUT LINKING the Wininet.lib ??

#8181
From: Remy Lebeau (TeamB)
Date: Sat, 13 Nov 2004 01:16
45 lines
3094 bytes
"Oren Halvani" <Spam@Me-Please.com> wrote in message
news:41955b2e$1@newsgroups.borland.com...

> let me see if i understand it right, if Wininet.lib is not a static
> library will my progrtam run on all Windows versions (Win 9.x,
> ME, NT, 2000, XP, 2003) ?

If you are dynamically loading the DLL via LoadLibrary(), then yes.  You
will, of course, have to make sure that when you use GetProcAddress() to
retreive a function pointer, that the pointer is not returned as NULL before
you try to call the function.  Some WinInet functions are not implemented on
all OS versions.

> if i use LoadLibary instead, will my programm even start
> if the WinInet.dll isn't existing, correct ??

Yes, it will start.

> of course its muuuuch easier to link the lib instead of calling
> thousand times LoadLibrary( ) and GetProcAddress( )

True, although you don't need to make thousands of calls.  You should only
call LoadLibrary() once, and keep the DLL loaded for the entire duration
that you are going to use it, and then call FreeLibrary() when you are not
using the DLL anymore.  As for GetProcAddress(), you only have to call it
once for each individual function that you are interested in.  Are you
planning on call a thousand separate WinInet functions?  I doubt it.

On the other hand, if you do statically link to the lib file, then not only
does the DLL itself have to exist, but so does every individual function
that your code calls.  If you run your program on a system that does not
have every single WinInet function that your code calls statically, then
your program will fail to start at all.

> i have to make sure, that my program can also run without the WinInet.dll

Then LoadLibrary() and GetProcAddress() are your only option.  Of course,
had you been using BCB 5 or 6, you could make use of their Delay-Load
mechanism to statically link to the DLL functions in your code while still
providing run-time loading of the DLL when needed.  A very nice feature to
use if you have it available.


Gambit
Technical Details
Message-ID: <41955ff6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!fu-berlin.de!border2.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
References: <419508ed$1@newsgroups.borland.com> <419516cd$1@newsgroups.borland.com> <41955b2e$1@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>
Subject: Re: Is it possible to use Wininet functions WITHOUT LINKING the Wininet.lib ??
Date: Fri, 12 Nov 2004 17:16:06 -0800
Lines: 47
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: <41955ff6@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100308470 68.69.17.41 (12 Nov 2004 17:14:30 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!fu-berlin.de!border2.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