home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / mnrccln.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.1 KB  |  77 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /* mail news client wrapper */
  20. /*Dynamic Library wrapper for loading on call*/
  21.  
  22. #include "stdafx.h"
  23. #include "mnrccln.h"
  24.  
  25. #ifdef WIN32
  26. #define MAILNEWSDLL "MNRC32.DLL"
  27. #else
  28. #define MAILNEWSDLL "MNRC16.DLL"
  29. #endif
  30.  
  31. HINSTANCE CMailNewsResourceDll::s_dllinstance=NULL;
  32. unsigned int CMailNewsResourceDll::s_refcount=0;
  33.  
  34. CMailNewsResourceDll::CMailNewsResourceDll()
  35. {
  36.     // Running under Win3.1, if the default drive is A or B and the disk
  37.     //  was removed, this tries to load from the default drive.
  38.     //  So change to C before loading. (A=1, B=2, C=3)
  39.     if( _getdrive() < 3 ){
  40.         _chdrive(3);
  41.     }
  42.     if (s_refcount)
  43.     {
  44.         s_dllinstance=LoadLibrary(MAILNEWSDLL);
  45.         s_refcount++;
  46.         return;
  47.     }
  48.     else
  49.     {
  50.         s_dllinstance=LoadLibrary(MAILNEWSDLL);
  51.         XP_ASSERT(s_dllinstance);
  52.         s_refcount++;
  53.         if(!s_dllinstance)
  54.             return;
  55.     }
  56. }
  57.  
  58. CMailNewsResourceDll::~CMailNewsResourceDll()
  59. {
  60. #ifdef WIN32
  61.     if (!FreeLibrary(s_dllinstance))
  62.         XP_ASSERT(0);
  63. #else
  64.     FreeLibrary(s_dllinstance);
  65. #endif
  66.        s_refcount--;
  67. }
  68.  
  69. HINSTANCE
  70. CMailNewsResourceDll::switchResources()
  71. {
  72.     XP_ASSERT(s_refcount);
  73.     HINSTANCE t_hinstance=AfxGetResourceHandle();
  74.     AfxSetResourceHandle(s_dllinstance);
  75.     return t_hinstance;
  76. }
  77.