home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / numega / sc501.exe / data1.cab / Examples / REGIFACE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  2.0 KB  |  83 lines

  1. /*
  2.  * RegIface.cpp
  3.  * $Header: /BoundsChecker/Examples/BUGBNCHX/REGIFACE.CPP 3     4/09/97 9:26a Bob $
  4.  *
  5.  * Description:
  6.  *  Functions for registering and unregistering the Interface Test Object.
  7.  *
  8.  * Notes:
  9.  *  <implementation notes go here>
  10.  *
  11.  ***********************************************************************
  12.  *
  13.  * Nu-Mega Technologies, Inc.
  14.  * P.O. Box 7780
  15.  * Nashua, NH 03060
  16.  *
  17.  * (c) Copyright 1994, 1995 Nu-Mega Technologies, Inc.
  18.  * ALL RIGHTS RESERVED.
  19.  *
  20.  ***********************************************************************
  21.  *
  22.  **********************************************************************/
  23. #include "stdafx.h"
  24.  
  25. BOOL CallStdApiOnIfaceDll ( LPCTSTR szFuncName ) 
  26. {
  27.    BOOL fRet = FALSE ;
  28.  
  29.    // Load the library and try to register it.
  30.    HINSTANCE hDll = LoadLibrary ( _T ( "IFACEDLL.DLL" ) ) ; 
  31.    if ( NULL != hDll )
  32.    {
  33.  
  34.       HRESULT (FAR* pfnStdApi) (void);
  35.  
  36.       pfnStdApi = (long(__cdecl *)(void))GetProcAddress ( hDll , szFuncName )  ;
  37.       if ( NULL != pfnStdApi ) 
  38.       {
  39.          // Even though GetProcAddress didn't return NULL, an access violation
  40.          // is still possible.
  41. #ifndef BCBVER
  42.          __try
  43.          {
  44. #else
  45.          try
  46.          {
  47. #endif                  
  48.             HRESULT hrReg = pfnStdApi ( ) ;
  49.             if ( ! FAILED ( hrReg ) )
  50.             {
  51.                fRet = TRUE ;
  52.             }
  53.          }
  54.          __except ( EXCEPTION_EXECUTE_HANDLER )
  55.          {
  56.          }
  57.       } // end if pfnStdApi != NULL
  58.  
  59.       FreeLibrary ( hDll ) ;
  60.    } // end if hDLL != NULL
  61.  
  62.    
  63.    // The one and only exit point from this function.
  64.    return fRet ;
  65. }
  66.  
  67.  
  68.  
  69. // Used to register the Interface Test object
  70. BOOL RegisterInterfaceTestObject ( ) 
  71. {
  72.    return ( CallStdApiOnIfaceDll ( _T ( "DllRegisterServer" ) ) ) ;
  73. }
  74.  
  75.  
  76.  
  77. // Used to un-register the Interface Test object
  78. BOOL UnregisterInterfaceTestObject ( ) 
  79. {
  80.    return ( CallStdApiOnIfaceDll ( _T ( "DllUnregisterServer" ) ) ) ;
  81. }
  82.  
  83.