windows-nt/Source/XPSP1/NT/printscan/print/spooler/spllib/loadlib.cxx
2020-09-26 16:20:57 +08:00

100 lines
1.3 KiB
C++

/*++
Copyright (c) 1995-1996 Microsoft Corporation
All rights reserved.
Module Name:
loadlib.cxx
Abstract:
Library Loader helper class
Author:
Steve Kiraly (SteveKi) 10/17/95
Revision History:
--*/
#include "spllibp.hxx"
#pragma hdrstop
TLibrary::
TLibrary(
LPCTSTR pszLibName
)
{
_hInst = LoadLibrary( pszLibName );
if( !_hInst )
{
DBGMSG( DBG_WARN, ( "Library.ctr: unable to load "TSTR"\n", pszLibName ));
}
}
TLibrary::
~TLibrary(
)
{
if( bValid() )
{
FreeLibrary( _hInst );
}
}
BOOL
TLibrary::
bValid(
VOID
) const
{
return _hInst != NULL;
}
FARPROC
TLibrary::
pfnGetProc(
IN LPCSTR pszProc
) const
{
FARPROC fpProc = bValid() ? GetProcAddress( _hInst, pszProc ) : NULL;
if( !fpProc )
{
DBGMSG( DBG_WARN, ( "Library.pfnGetProc: failed %s\n", pszProc ));
}
return fpProc;
}
FARPROC
TLibrary::
pfnGetProc(
IN UINT uOrdinal
) const
{
FARPROC fpProc = bValid() ? GetProcAddress( _hInst, (LPCSTR)MAKELPARAM( uOrdinal, 0 ) ) : NULL;
if( !fpProc )
{
DBGMSG( DBG_WARN, ( "Library.pfnGetProc: failed %d\n", uOrdinal ));
}
return fpProc;
}
HINSTANCE
TLibrary::
hInst(
VOID
) const
{
return _hInst;
}