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.

70 lines
1.8 KiB

  1. // low-level support for the add-on services
  2. // this may be superceeded if the add-on services go to ocxs
  3. #include "stdafx.h"
  4. #include "keyobjs.h"
  5. #include "addons.h"
  6. //----------------------------------------------------------------
  7. // construction
  8. //----------------------------------------------------------------
  9. CAddOnService::CAddOnService() :
  10. m_library( NULL ),
  11. m_proc( NULL )
  12. {;}
  13. //----------------------------------------------------------------
  14. // destruction
  15. //----------------------------------------------------------------
  16. CAddOnService::~CAddOnService()
  17. {
  18. // free the library if it has been loaded
  19. if ( m_library )
  20. FreeLibrary( m_library );
  21. m_library = NULL;
  22. }
  23. //----------------------------------------------------------------
  24. // Initialize the service. Loads the dll and makes sure
  25. // the callback we need is there
  26. //----------------------------------------------------------------
  27. BOOL CAddOnService::FInitializeAddOnService( CString &szName )
  28. {
  29. // load the library module
  30. m_library = LoadLibrary( szName );
  31. DWORD err = GetLastError();
  32. // did we successfully load the library?
  33. if ( !m_library ) return FALSE;
  34. // get the main procedure address
  35. m_proc = (LOADPROC)GetProcAddress( m_library, "LoadService" );
  36. // did we successfully load the procedure address?
  37. if ( !m_proc )
  38. {
  39. FreeLibrary( m_library );
  40. m_library = NULL;
  41. return FALSE;
  42. }
  43. // success!
  44. return TRUE;
  45. }
  46. //----------------------------------------------------------------
  47. // call into the dll to create a new service object that
  48. // gets connected to a machine object
  49. //----------------------------------------------------------------
  50. BOOL CAddOnService::LoadService( CMachine* pMachine )
  51. {
  52. ASSERT( m_library );
  53. ASSERT( m_proc );
  54. // call into the dll to load a service object into the machine object
  55. return (*m_proc)( pMachine );
  56. }