* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-
- Change History (most recent first):
-
-$Log: ExplorerPlugin.cpp,v $
-Revision 1.9 2006/08/14 23:24:00 cheshire
-Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
-
-Revision 1.8 2005/06/30 18:01:54 shersche
-<rdar://problem/4130635> Cause IE to rebuild cache so we don't have to reboot following an install.
-
-Revision 1.7 2005/02/23 02:00:45 shersche
-<rdar://problem/4014479> Delete all the registry entries when component is unregistered
-
-Revision 1.6 2005/01/25 17:56:45 shersche
-<rdar://problem/3911084> Load resource DLLs, get icons and bitmaps from resource DLLs
-Bug #: 3911084
-
-Revision 1.5 2004/09/15 10:33:54 shersche
-<rdar://problem/3721611> Install XP toolbar button (8 bit mask) if running on XP platform, otherwise install 1 bit mask toolbar button
-Bug #: 3721611
-
-Revision 1.4 2004/07/13 21:24:21 rpantos
-Fix for <rdar://problem/3701120>.
-
-Revision 1.3 2004/06/26 14:12:07 shersche
-Register the toolbar button
-
-Revision 1.2 2004/06/24 20:09:39 shersche
-Change text
-Submitted by: herscher
-
-Revision 1.1 2004/06/18 04:34:59 rpantos
-Move to Clients from mDNSWindows
-
-Revision 1.1 2004/01/30 03:01:56 bradley
-Explorer Plugin to browse for DNS-SD advertised Web and FTP servers from within Internet Explorer.
-
-*/
+ */
#include "StdAfx.h"
// Prototypes
//===========================================================================================================================
-// DLL Exports
-
-extern "C" BOOL WINAPI DllMain( HINSTANCE inInstance, DWORD inReason, LPVOID inReserved );
-
-// MFC Support
-
-DEBUG_LOCAL OSStatus MFCDLLProcessAttach( HINSTANCE inInstance );
-DEBUG_LOCAL void MFCDLLProcessDetach( HINSTANCE inInstance );
-DEBUG_LOCAL void MFCDLLThreadDetach( HINSTANCE inInstance );
-
// Utilities
DEBUG_LOCAL OSStatus RegisterServer( HINSTANCE inInstance, CLSID inCLSID, LPCTSTR inName );
// Globals
//===========================================================================================================================
-HINSTANCE gInstance = NULL;
-int gDLLRefCount = 0;
-CWinApp gApp;
+HINSTANCE gInstance = NULL;
+int gDLLRefCount = 0;
+CExplorerPluginApp gApp;
#if 0
#pragma mark -
#endif
//===========================================================================================================================
-// DllMain
+// CExplorerPluginApp::CExplorerPluginApp
//===========================================================================================================================
-BOOL WINAPI DllMain( HINSTANCE inInstance, DWORD inReason, LPVOID inReserved )
+IMPLEMENT_DYNAMIC(CExplorerPluginApp, CWinApp);
+
+CExplorerPluginApp::CExplorerPluginApp()
{
- BOOL ok;
- OSStatus err;
-
- DEBUG_UNUSED( inReserved );
-
- ok = TRUE;
- switch( inReason )
- {
- case DLL_PROCESS_ATTACH:
- gInstance = inInstance;
- debug_initialize( kDebugOutputTypeWindowsEventLog, "DNSServices Bar", inInstance );
- debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );
- dlog( kDebugLevelTrace, "\nDllMain: process attach\n" );
-
- err = MFCDLLProcessAttach( inInstance );
- ok = ( err == kNoErr );
- require_noerr( err, exit );
- break;
-
- case DLL_PROCESS_DETACH:
- dlog( kDebugLevelTrace, "DllMain: process detach\n" );
- MFCDLLProcessDetach( inInstance );
- break;
-
- case DLL_THREAD_ATTACH:
- dlog( kDebugLevelTrace, "DllMain: thread attach\n" );
- break;
-
- case DLL_THREAD_DETACH:
- dlog( kDebugLevelTrace, "DllMain: thread detach\n" );
- MFCDLLThreadDetach( inInstance );
- break;
-
- default:
- dlog( kDebugLevelTrace, "DllMain: unknown reason code (%d)\n",inReason );
- break;
- }
-
+}
+
+
+//===========================================================================================================================
+// CExplorerPluginApp::~CExplorerPluginApp
+//===========================================================================================================================
+
+CExplorerPluginApp::~CExplorerPluginApp()
+{
+}
+
+
+//===========================================================================================================================
+// CExplorerPluginApp::InitInstance
+//===========================================================================================================================
+
+BOOL
+CExplorerPluginApp::InitInstance()
+{
+ wchar_t resource[MAX_PATH];
+ OSStatus err;
+ int res;
+ HINSTANCE inInstance;
+
+ inInstance = AfxGetInstanceHandle();
+ gInstance = inInstance;
+
+ debug_initialize( kDebugOutputTypeWindowsEventLog, "DNSServices Bar", inInstance );
+ debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );
+ dlog( kDebugLevelTrace, "\nCCPApp::InitInstance\n" );
+
+ res = PathForResource( inInstance, L"ExplorerPluginResources.dll", resource, MAX_PATH );
+
+ err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
+ require_noerr( err, exit );
+
+ g_nonLocalizedResources = LoadLibrary( resource );
+ translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
+ require_noerr( err, exit );
+
+ g_nonLocalizedResourcesName = resource;
+
+ res = PathForResource( inInstance, L"ExplorerPluginLocalized.dll", resource, MAX_PATH );
+ err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
+ require_noerr( err, exit );
+
+ g_localizedResources = LoadLibrary( resource );
+ translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
+ require_noerr( err, exit );
+
+ AfxSetResourceHandle( g_localizedResources );
+
exit:
- return( ok );
+
+ return TRUE;
}
+
+//===========================================================================================================================
+// CExplorerPluginApp::ExitInstance
+//===========================================================================================================================
+
+int
+CExplorerPluginApp::ExitInstance()
+{
+ return 0;
+}
+
+
+
//===========================================================================================================================
// DllCanUnloadNow
//===========================================================================================================================
return( err );
}
-#if 0
-#pragma mark -
-#pragma mark == MFC Support ==
-#endif
-
-//===========================================================================================================================
-// MFCDLLProcessAttach
-//===========================================================================================================================
-
-DEBUG_LOCAL OSStatus MFCDLLProcessAttach( HINSTANCE inInstance )
-{
- wchar_t resource[MAX_PATH];
- OSStatus err;
- _AFX_THREAD_STATE * threadState;
- AFX_MODULE_STATE * previousModuleState;
- BOOL ok;
- int res;
- CWinApp * app;
-
- app = NULL;
-
- // Simulate what is done in dllmodul.cpp.
-
- threadState = AfxGetThreadState();
- check( threadState );
- previousModuleState = threadState->m_pPrevModuleState;
-
- ok = AfxWinInit( inInstance, NULL, TEXT( "" ), 0 );
- require_action( ok, exit, err = kUnknownErr );
-
- app = AfxGetApp();
- require_action( ok, exit, err = kNotInitializedErr );
-
- // Before we load the resources, let's load the error string
-
- // errorMessage.LoadString( IDS_REINSTALL );
- // errorCaption.LoadString( IDS_REINSTALL_CAPTION );
-
- // Load Resources
-
- res = PathForResource( inInstance, L"ExplorerPluginResources.dll", resource, MAX_PATH );
-
- err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
- require_noerr( err, exit );
-
- g_nonLocalizedResources = LoadLibrary( resource );
- translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
- require_noerr( err, exit );
-
- g_nonLocalizedResourcesName = resource;
-
- res = PathForResource( inInstance, L"ExplorerPluginLocalized.dll", resource, MAX_PATH );
- err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
- require_noerr( err, exit );
-
- g_localizedResources = LoadLibrary( resource );
- translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
- require_noerr( err, exit );
-
- AfxSetResourceHandle( g_localizedResources );
-
- ok = app->InitInstance();
- require_action( ok, exit, err = kUnknownErr );
-
- threadState->m_pPrevModuleState = previousModuleState;
- threadState = NULL;
- AfxInitLocalData( inInstance );
- err = kNoErr;
-
-exit:
- if( err )
- {
- if( app )
- {
- app->ExitInstance();
- }
- AfxWinTerm();
- }
- if( threadState )
- {
- threadState->m_pPrevModuleState = previousModuleState;
- }
- return( err );
-}
-
-//===========================================================================================================================
-// MFCDLLProcessDetach
-//===========================================================================================================================
-
-DEBUG_LOCAL void MFCDLLProcessDetach( HINSTANCE inInstance )
-{
- CWinApp * app;
-
- // Simulate what is done in dllmodul.cpp.
-
- app = AfxGetApp();
- if( app )
- {
- app->ExitInstance();
- }
-
-#if( DEBUG )
- if( AfxGetModuleThreadState()->m_nTempMapLock != 0 )
- {
- dlog( kDebugLevelWarning, "Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock );
- }
-#endif
-
- AfxLockTempMaps();
- AfxUnlockTempMaps( -1 );
-
- // Terminate the library before destructors are called.
-
- AfxWinTerm();
- AfxTermLocalData( inInstance, TRUE );
-}
-
-//===========================================================================================================================
-// MFCDLLFinalize
-//===========================================================================================================================
-
-DEBUG_LOCAL void MFCDLLThreadDetach( HINSTANCE inInstance )
-{
- // Simulate what is done in dllmodul.cpp.
-
-#if( DEBUG )
- if( AfxGetModuleThreadState()->m_nTempMapLock != 0 )
- {
- dlog( kDebugLevelWarning, "Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock );
- }
-#endif
-
- AfxLockTempMaps();
- AfxUnlockTempMaps( -1 );
- AfxTermThread( inInstance );
-}
#if 0
#pragma mark -