| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Locating Windows DLL without error? |
[Directed to Frank, Brenton, and other Windows programmers hiding out there.]
I want to be able to check to see if a particular DLL is present, and if
so, then call a routine in that DLL .. but if not, then *not* have the
Windows "Cannot find XXX.DLL" message appear. I'm using MFC 2.5.
At present, my code looks like this:
-----[ snip, snip ]-----
BOOL CTheApp::InitInstance()
{
HINSTANCE hinstWSA = LoadLibrary("WINSOCK.DLL");
if( (UINT)hinstWSA > 32 )
{
WinSockInstalled = TRUE;
strcpy( wsd, "Winsock 1.1-compliant Transport Located..." );
FreeLibrary(hinstWSA);
}
else
WinSockInstalled = FALSE;
-----[ snip, snip ]-----
Now, this code will work, and correctly output the right messages when
requested to do so; but during that LoadLibrary() function, if WINSOCK.DLL
is not found then the dreaded "Cannot find.." error appears. Is
there any way to trap that error, or ignore it? I know MFC supports
exceptions, but I can't seem to find one that'll match this particular
circumstance.
While I'm at it, does Windows have a "search the $PATH" style
function? (ie., given the PATH environment variable, search it for the
specified file) Or am I stuck using compiler-specific functions here?
I've already got my own such functions (written to overcome deficiencies in
the AIX standard library), but I'd rather use a Windows API for this.
Thanks..
- dave
d.begley{at}ieee.org
---
* Origin: [ epicentre of the universe -- sydney australia ] (3:711/934.4)SEEN-BY: 711/934 @PATH: 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.