bool WdeDDEDumpConversation( HINSTANCE inst ) { HCONV hconv; HSZ hservice; HSZ htopic; bool ok; ok = WdeDDEStart( inst ); if( ok ) { hservice = DdeCreateStringHandle( IdInst, WRE_SERVICE_NAME, CP_WINANSI ); ok = (hservice != (HSZ)NULL); } if( ok ) { htopic = DdeCreateStringHandle( IdInst, WRE_DIALOG_DUMP, CP_WINANSI ); ok = (htopic != (HSZ)NULL); } if( ok ) { // We expect the server to reject this connect attempt. // If it doesn't, then we terminate the conversation. hconv = DdeConnect( IdInst, hservice, htopic, (LPVOID)NULL ); if( hconv != (HCONV)NULL ) { DdeDisconnect( hconv ); } } if( hservice != (HSZ)NULL ) { DdeFreeStringHandle( IdInst, hservice ); } if( htopic != (HSZ)NULL ) { DdeFreeStringHandle( IdInst, htopic ); } WdeDDEEnd(); if( !ok ) { WdeDisplayErrorMsg( WDE_DDEDEATHMSG ); } return( ok ); }
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow ) { MSG msg; #ifndef __NT__ #if 0 HWND win; HWND child; #endif #endif /* touch unused vars to get rid of warning */ _wde_touch( lpszCmdLine ); _wde_touch( nCmdShow ); #ifdef __NT__ _wde_touch( hinstPrevious ); #endif #if defined( __NT__ ) && !defined( __WATCOMC__ ) _argc = __argc; _argv = __argv; #endif WRInit(); WdeInitDisplayError( hinstCurrent ); /* store the handle to this instance of Wde in a static variable */ hInstWde = hinstCurrent; //check we are running in DDE mode IsDDE = WdeIsDDEArgs( _argv, _argc ); WdeFirstInst = (hinstPrevious == NULL); WdeInitEditClass(); /* is this the first instance of the application? */ #ifndef __NT__ if( WdeFirstInst ) { #endif /* if so call the routine to initialize the application */ if( !WdeInit( hinstCurrent ) ) { if( IsDDE ) { WdeDDEDumpConversation( hinstCurrent ); } return( FALSE ); } #ifndef __NT__ } #if 0 else if( IsDDE ) { WdeDisplayErrorMsg( WDE_NOMULTIPLEINSTANCES ); WdeDDEDumpConversation( hinstCurrent ); return( FALSE ); } else { win = FindWindow( WdeMainClass, NULL ); if( win != NULL ) { child = GetLastActivePopup( win ); PostMessage( win, WM_USER, 0, 0 ); BringWindowToTop( win ); if( child != (HWND)NULL && child != win ) { BringWindowToTop( child ); } } else { WdeDisplayErrorMsg( WDE_NOMULTIPLEINSTANCES ); } return( FALSE ); } #endif #endif if( !WdeInitInst( hinstCurrent ) ) { WdeDisplayErrorMsg( WDE_INITFAILED ); if( IsDDE ) { WdeDDEDumpConversation( hinstCurrent ); } return( FALSE ); } if( IsDDE ) { if( WdeDDEStart( hinstCurrent ) ) { if( !WdeDDEStartConversation() ) { WdeDisplayErrorMsg( WDE_DDEINITFAILED ); PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 ); } } else { WdeDisplayErrorMsg( WDE_DDEINITFAILED ); PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 ); } } WdeEnableMenuInput( TRUE ); if( setjmp( WdeEnv ) ) { PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 ); if( setjmp( WdeEnv ) ) { WdeDisplayErrorMsg( WDE_EXCEPTIONDURINGABNORMALEXIT ); exit( -1 ); } WdePushEnv( &WdeEnv ); } else { WdePushEnv( &WdeEnv ); WdeProcessArgs( _argv, _argc ); } if( !WdeGetNumRes() ) { WdeCreateNewResource( NULL ); } /* create the message loop */ while( GetMessage( &msg, (HWND)NULL, 0, 0 ) ) { if( !WdeIsTestMessage( &msg ) && !WdeIsInfoMessage( &msg ) && !WRIsWRDialogMsg( &msg ) ) { if( !WdeWasAcceleratorHandled( &msg ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } } if( IsDDE ) { WdeDDEEndConversation(); } WdePopEnv( &WdeEnv ); if( IsDDE ) { WdeDDEEnd(); } WRFini(); return( msg.wParam ); }