From 2dd747e17f4a54e5b1ff0dcfebd5a49cb08b6090 Mon Sep 17 00:00:00 2001 From: "syd%netscape.com" Date: Wed, 12 Jul 2000 22:45:11 +0000 Subject: [PATCH] r=law, vishy This is part of a ns commercial nsbeta2+ bug fix. Instead of hardcoding the DDE application name (e.g., Mozilla), read it from a string table for win32. git-svn-id: svn://10.0.0.236/trunk@74118 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/bootstrap/nsNativeAppSupportWin.cpp | 130 +++++++++--------- .../xpfe/bootstrap/nsNativeAppSupportWin.h | 3 + mozilla/xpfe/bootstrap/splash.rc | 5 + 3 files changed, 76 insertions(+), 62 deletions(-) diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index 6e5f9ee177b..bd938b677bc 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -548,33 +548,38 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) { // Grab mutex before doing DdeInitialize! This is // important (see comment above). - Mutex ddeLock = Mutex( MOZ_DDE_MUTEX_NAME ); - if ( ddeLock.Lock( MOZ_DDE_START_TIMEOUT ) ) { - // Initialize DDE. - UINT rc = DdeInitialize( &mInstance, + int retval; + UINT id = ID_DDE_APPLICATION_NAME; + char nameBuf[ 128 ]; + retval = LoadString( (HINSTANCE) NULL, id, (LPTSTR) nameBuf, sizeof(nameBuf) ); + if ( retval != 0 ) { + Mutex ddeLock = Mutex( MOZ_DDE_MUTEX_NAME ); + if ( ddeLock.Lock( MOZ_DDE_START_TIMEOUT ) ) { + // Initialize DDE. + UINT rc = DdeInitialize( &mInstance, nsNativeAppSupportWin::HandleDDENotification, APPCLASS_STANDARD, 0 ); - if ( rc == DMLERR_NO_ERROR ) { - mApplication = DdeCreateStringHandle( mInstance, - MOZ_DDE_APPLICATION, + if ( rc == DMLERR_NO_ERROR ) { + mApplication = DdeCreateStringHandle( mInstance, + nameBuf, CP_WINANSI ); - mTopic = DdeCreateStringHandle( mInstance, + mTopic = DdeCreateStringHandle( mInstance, MOZ_DDE_TOPIC, CP_WINANSI ); - if ( mApplication && mTopic ) { - // Everything OK so far, try to connect to previusly - // started Mozilla. - HCONV hconv = DdeConnect( mInstance, mApplication, mTopic, 0 ); + if ( mApplication && mTopic ) { + // Everything OK so far, try to connect to previusly + // started Mozilla. + HCONV hconv = DdeConnect( mInstance, mApplication, mTopic, 0 ); - if ( hconv ) { - // We're the client... - // Get command line to pass to server. - LPTSTR cmd = GetCommandLine(); - #if MOZ_DEBUG_DDE - printf( "Acting as DDE client, cmd=%s\n", cmd ); - #endif - rc = (UINT)DdeClientTransaction( (LPBYTE)cmd, + if ( hconv ) { + // We're the client... + // Get command line to pass to server. + LPTSTR cmd = GetCommandLine(); + #if MOZ_DEBUG_DDE + printf( "Acting as DDE client, cmd=%s\n", cmd ); + #endif + rc = (UINT)DdeClientTransaction( (LPBYTE)cmd, strlen( cmd ) + 1, hconv, 0, @@ -582,54 +587,55 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) { XTYP_EXECUTE, MOZ_DDE_EXEC_TIMEOUT, 0 ); - if ( rc ) { - // Inform caller that request was issued. - rv = NS_OK; - } else { - // Something went wrong. Not much we can do, though... - #if MOZ_DEBUG_DDE - printf( "DdeClientTransaction failed, error = 0x%08X\n", + if ( rc ) { + // Inform caller that request was issued. + rv = NS_OK; + } else { + // Something went wrong. Not much we can do, though... + #if MOZ_DEBUG_DDE + printf( "DdeClientTransaction failed, error = 0x%08X\n", (int)DdeGetLastError( mInstance ) ); - #endif - } - } else { - // We're going to be the server... - #if MOZ_DEBUG_DDE - printf( "Setting up DDE server...\n" ); - #endif + #endif + } + } else { + // We're going to be the server... + #if MOZ_DEBUG_DDE + printf( "Setting up DDE server...\n" ); + #endif - // Next step is to register a DDE service. - rc = (UINT)DdeNameService( mInstance, mApplication, 0, DNS_REGISTER ); + // Next step is to register a DDE service. + rc = (UINT)DdeNameService( mInstance, mApplication, 0, DNS_REGISTER ); - if ( rc ) { - #if MOZ_DEBUG_DDE - printf( "...DDE server started\n" ); - #endif - // Tell app to do its thing. - *aResult = PR_TRUE; - rv = NS_OK; - } else { - #if MOZ_DEBUG_DDE - printf( "DdeNameService failed, error = 0x%08X\n", + if ( rc ) { + #if MOZ_DEBUG_DDE + printf( "...DDE server started\n" ); + #endif + // Tell app to do its thing. + *aResult = PR_TRUE; + rv = NS_OK; + } else { + #if MOZ_DEBUG_DDE + printf( "DdeNameService failed, error = 0x%08X\n", (int)DdeGetLastError( mInstance ) ); - #endif - } - } - } else { - #if MOZ_DEBUG_DDE - printf( "DdeCreateStringHandle failed, error = 0x%08X\n", + #endif + } + } + } else { + #if MOZ_DEBUG_DDE + printf( "DdeCreateStringHandle failed, error = 0x%08X\n", (int)DdeGetLastError( mInstance ) ); - #endif - } - } else { - #if MOZ_DEBUG_DDE - printf( "DdeInitialize failed, error = 0x%08X\n", (int)rc ); - #endif - } + #endif + } + } else { + #if MOZ_DEBUG_DDE + printf( "DdeInitialize failed, error = 0x%08X\n", (int)rc ); + #endif + } - // Release mutex. - ddeLock.Unlock(); - } + // Release mutex. + ddeLock.Unlock(); + } + } // Clean up. The only case in which we need to preserve DDE stuff // is if we're going to be acting as server. diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h index cc5dcf80c5c..e25426efdba 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.h @@ -27,3 +27,6 @@ // Splash screen bitmap ID. #define IDB_SPLASH 101 +// DDE application name +#define ID_DDE_APPLICATION_NAME 102 + diff --git a/mozilla/xpfe/bootstrap/splash.rc b/mozilla/xpfe/bootstrap/splash.rc index 6e6f068d660..2bf619fee1a 100644 --- a/mozilla/xpfe/bootstrap/splash.rc +++ b/mozilla/xpfe/bootstrap/splash.rc @@ -46,3 +46,8 @@ IDD_SPLASH DIALOGEX // Splash screen bitmap. IDB_SPLASH BITMAP "splash.bmp" + +STRINGTABLE DISCARDABLE +BEGIN + ID_DDE_APPLICATION_NAME, "Mozilla" +END \ No newline at end of file