home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / apptrn.zip / RESDLL.CPP < prev    next >
C/C++ Source or Header  |  1996-03-27  |  2KB  |  71 lines

  1. /************************************************
  2. *                                                *
  3. *                  RESDLL.CPP                    *
  4. *                                                *
  5. *                  ResDll Library                    *
  6. *                                                *
  7. *************************************************
  8. *                                                *
  9. *        by Software Builders (C) 1995-96        *
  10. *                                                *
  11. *        Visual C++ 1.52 for Windows 3.1            *
  12. *                                                *
  13. ************************************************/
  14.  
  15. #include    "Windows.h"
  16.  
  17. static    HINSTANCE     hDLLInstance=NULL;
  18.  
  19.  
  20. //-----------------------------------------------------------------------------------
  21. //    DLL Entry Point
  22. extern "C" int CALLBACK LibMain(HINSTANCE     p_hInstance,        //    handle of library instance
  23.                                 WORD         p_wDataSeg,            //    library data segment
  24.                                 WORD         p_wHeapSize,        //    default heap size
  25.                                 LPSTR        p_lpszCmdLine)        //    command-line arguments
  26. {
  27.     hDLLInstance=p_hInstance;
  28.     return 1;   // ok
  29. };
  30.  
  31. //-----------------------------------------------------------------------------------
  32. //    Application call this make DLL register VBControl (VBX)
  33. extern "C" BOOL FAR PASCAL _loadds RegisterVBX(HINSTANCE p_hAppInstance)    //    Application hInstance
  34. {
  35.     WNDCLASS wndClass;
  36.     ::OutputDebugString("RegisterVBX\r\n");
  37.     
  38.     
  39.     if    (::GetClassInfo(hDLLInstance,"VBControl",&wndClass)==0)    //    If the class VBControl is not already registred by DLL
  40.     {
  41.         BOOL fOk=::GetClassInfo(p_hAppInstance,"VBControl",&wndClass);    //    Get App ClasInfo for VBControl
  42.         if    (fOk)
  43.         {
  44.             wndClass.hInstance = hDLLInstance;     // Change the instance handle so it is that of the DLL and not the App.
  45.             fOk=::RegisterClass(&wndClass);        // Register the class
  46.             if    (!fOk)
  47.                 ::OutputDebugString("RegisterVBX: RegisterClass() Failed\r\n");
  48.         }
  49.         else
  50.             ::OutputDebugString("RegisterVBX: GetClassInfo(p_hAppInstance) Failed\r\n");
  51.     };
  52.     return TRUE;   // ok
  53. }
  54.  
  55. //-----------------------------------------------------------------------------------
  56. //    Exit DLL
  57. extern "C" int FAR PASCAL _WEP(int)
  58. {
  59.     WNDCLASS wndClass;
  60.     ::OutputDebugString("WEP-RegisterVBX\r\n");
  61.     
  62.     if    (::GetClassInfo(hDLLInstance,"VBControl",&wndClass))    //    If the class VBControl is registred by DLL
  63.     {
  64.         BOOL    fOk=::UnregisterClass("VBControl",hDLLInstance);  // Unregister It
  65.         if    (!fOk)
  66.             ::OutputDebugString("_WEP(: UnregisterClass() Failed\r\n");
  67.     };
  68.     return 1;
  69. };
  70.  
  71.