Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. loadlib.cxx
  6. Abstract:
  7. Library Loader helper class
  8. Author:
  9. Steve Kiraly (SteveKi) 10/17/95
  10. Revision History:
  11. --*/
  12. #include "spllibp.hxx"
  13. #pragma hdrstop
  14. TLibrary::
  15. TLibrary(
  16. LPCTSTR pszLibName
  17. )
  18. {
  19. _hInst = LoadLibrary( pszLibName );
  20. if( !_hInst )
  21. {
  22. DBGMSG( DBG_WARN, ( "Library.ctr: unable to load "TSTR"\n", pszLibName ));
  23. }
  24. }
  25. TLibrary::
  26. ~TLibrary(
  27. )
  28. {
  29. if( bValid() )
  30. {
  31. FreeLibrary( _hInst );
  32. }
  33. }
  34. BOOL
  35. TLibrary::
  36. bValid(
  37. VOID
  38. ) const
  39. {
  40. return _hInst != NULL;
  41. }
  42. FARPROC
  43. TLibrary::
  44. pfnGetProc(
  45. IN LPCSTR pszProc
  46. ) const
  47. {
  48. FARPROC fpProc = bValid() ? GetProcAddress( _hInst, pszProc ) : NULL;
  49. if( !fpProc )
  50. {
  51. DBGMSG( DBG_WARN, ( "Library.pfnGetProc: failed %s\n", pszProc ));
  52. }
  53. return fpProc;
  54. }
  55. FARPROC
  56. TLibrary::
  57. pfnGetProc(
  58. IN UINT uOrdinal
  59. ) const
  60. {
  61. FARPROC fpProc = bValid() ? GetProcAddress( _hInst, (LPCSTR)MAKELPARAM( uOrdinal, 0 ) ) : NULL;
  62. if( !fpProc )
  63. {
  64. DBGMSG( DBG_WARN, ( "Library.pfnGetProc: failed %d\n", uOrdinal ));
  65. }
  66. return fpProc;
  67. }
  68. HINSTANCE
  69. TLibrary::
  70. hInst(
  71. VOID
  72. ) const
  73. {
  74. return _hInst;
  75. }