Beispiel #1
0
JNIEXPORT jint JNICALL Java_de_walware_ecommons_io_win_DDEClient_ddeExecute(
		JNIEnv* env, jclass obj, jstring server, jstring topic, jstring command)
{
	// Pull unicode strings from the java arguments
	const jchar *szServer = env->GetStringChars(server, 0);
	const jchar *szTopic =  env->GetStringChars(topic, 0);
	const jchar *szCommand = env->GetStringChars(command, 0);
	
	// Init the DDEM Library
	DWORD idInst = 0;
	UINT iReturn = DdeInitialize(&idInst, (PFNCALLBACK) DdeCallback,
			APPCLASS_STANDARD | APPCMD_CLIENTONLY, 0 );
	if (iReturn != DMLERR_NO_ERROR)
	{
		return 1;
	}
	
	// Connect to the DDE server
	HSZ hszServer = DdeCreateStringHandle(idInst, (WCHAR*) szServer, 0);
	HSZ hszTopic = DdeCreateStringHandle(idInst, (WCHAR*) szTopic, 0);
	HCONV hConv = DdeConnect(idInst, hszServer, hszTopic, NULL);
	
	// Free up some resources
	DdeFreeStringHandle(idInst, hszServer);
	env->ReleaseStringChars(server, szServer);
	DdeFreeStringHandle(idInst, hszTopic);
	env->ReleaseStringChars(topic, szTopic);
	
	// Make sure we're connected
	if (hConv == NULL)
	{
		DdeUninitialize(idInst);
		env->ReleaseStringChars(command, szCommand);
		return 2;
	}
	
	// Prepare data for transaction
	HDDEDATA hData = DdeCreateDataHandle(idInst, (LPBYTE) szCommand,
			(lstrlen((WCHAR*) szCommand) + 1) * sizeof(WCHAR), 0L, 0L, CF_UNICODETEXT, 0);
	env->ReleaseStringChars(command, szCommand);
	
	// Data is OK?
	if (hData == NULL)
	{
		DdeDisconnect(hConv);
		DdeUninitialize(idInst);
		return 3;
	}
	else
	{
		DdeClientTransaction((LPBYTE) hData, 0xFFFFFFFF, hConv, 0L, 0,
				XTYP_EXECUTE, TIMEOUT_ASYNC, NULL);
	}
	
	// Clean up
	DdeDisconnect(hConv);
	DdeUninitialize(idInst);
	
	return 0;
}
HDDEDATA CALLBACK SleepyApi::Impl::OnDdeCallback(UINT type, UINT fmt, HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG_PTR data1, ULONG_PTR data2)
{
	if (!m_instance)
		return FALSE;

	if (type==XTYP_REGISTER&&!m_instance->m_conv)
	{
		char help[30];
		DdeQueryStringA(m_instance->m_appId,hsz1,help,sizeof(help),CP_WINANSI);
		if (!strcmp(help,"VerySleepyProfilerServer"))
		{
			m_instance->TryConnect();
		}
	}
	if (type==XTYP_UNREGISTER&&m_instance->m_conv)
	{
		char help[30];
		DdeQueryStringA(m_instance->m_appId,hsz1,help,sizeof(help),CP_WINANSI);
		if (!strcmp(help,"VerySleepyProfilerServer"))
		{
			DdeDisconnect(m_instance->m_conv);
			m_instance->m_conv=NULL;
		}
	}
	return FALSE;
}
Beispiel #3
0
/*
 * IEDDEEndConversation
 */
void IEDDEEndConversation( void )
{
    if( IEClientConv != (HCONV)NULL ) {
        DdeDisconnect( IEClientConv );
        IEClientConv = (HCONV)NULL;
    }
    if( IEServerConv != (HCONV)NULL ) {
        DdeDisconnect( IEServerConv );
        IEServerConv = (HCONV)NULL;
    }
    if( hService != (HSZ)NULL ) {
        DdeFreeStringHandle( IdInst, hService );
        hService = (HSZ)NULL;
    }

} /* IEDDEEndConversation */
Beispiel #4
0
//Disconnect from DDE server
int disconnectDDE()
{
    #ifdef _ddedebug
    printf("Disconnected DDE\n");
    #endif
    DdeDisconnect(Conversation);
}
//--------------------
//
void	DDEIntegratorClient::Disconnect ()
{
	if (m_hConv)
	{
		DdeDisconnect(m_hConv);
		m_hConv	= NULL;
	}
}
Beispiel #6
0
//------DDE経由で取得------------------------------------
bool GetUrlByDDE( CString browser, CString &URL )
{
    bool    ret    = false;
    DWORD   idInst = 0;
    UINT    result = DdeInitialize( &idInst, DdeCallback,
                                    APPCMD_CLIENTONLY, 0L );

    URL = _T("");
    if ( result == DMLERR_NO_ERROR ) {
        LPSTR   lpszApplication = browser.GetBuffer(0);
        LPSTR   lpszTopic       = "WWW_GetWindowInfo";
        HSZ     hszApplication  = DdeCreateStringHandle(
                                        idInst, lpszApplication, CP_WINANSI );
        HSZ     hszTopic        = DdeCreateStringHandle(
                                        idInst, lpszTopic, CP_WINANSI );
        HSZ     hszItem         = DdeCreateStringHandle(
                                        idInst, "-1", CP_WINANSI );

        if ( hszApplication && hszTopic && hszItem ) {
            HCONV hConv = DdeConnect(idInst, hszApplication, hszTopic, NULL);

            if ( hConv ) {
                HDDEDATA    hData   = DdeClientTransaction(
                                          NULL, 0, hConv, hszItem,
                                          CF_TEXT, XTYP_REQUEST, 1000, NULL );
                if ( hData ) {
                    char    *pStart = (char *)DdeAccessData( hData, NULL );

                    if ( pStart ) {
                        while ( *pStart++ != '"' )
                            ;
                        if ( *pStart ) {
                            char    *pEnd = pStart;
                            while ( *pEnd != '"' )
                                pEnd++;

                            *pEnd = NUL;
                            URL   = pStart;
                            ret   = true;
                        }
                    }
                }

                DdeDisconnect( hConv );
            }
        }

        if ( hszItem )
            DdeFreeStringHandle( idInst, hszItem );
        if ( hszTopic )
            DdeFreeStringHandle( idInst, hszTopic );
        if ( hszApplication )
            DdeFreeStringHandle( idInst, hszApplication );
        DdeUninitialize( idInst );
    }

    return ( ret );
}
Beispiel #7
0
static int dde_open_pdf (const char *exename,
			 const char *fname,
			 const char *dest)
{
    DWORD session = 0;
    HCONV conversation = NULL;
    char ddename[32];
    char *buf = NULL;
    int err = 0;

    /* Try to figure out the name of the DDE service
       provided by Acrobat Reader or Acrobat (oh, Adobe!)
    */
    err = get_pdf_service_name(ddename, exename);
    if (err) {
	return err;
    }

    buf = calloc(strlen(fname) + strlen(dest) + 32, 1);

    session = open_dde_conversation("control", exename, ddename,
				    &conversation);
    if (session == 0) {
	free(buf);
	return 1;
    }

    /* Adobe DDE commands only work on documents opened
       by DDE. It's therefore necessary to close the document
       first (if it's already open) then reopen it.
    */    

    sprintf(buf, "[DocClose(\"%s\")]", fname);
    exec_dde_command(buf, conversation, session);
    sprintf(buf, "[DocOpen(\"%s\")]", fname);
    exec_dde_command(buf, conversation, session);
    if (strstr(ddename, "wR") == NULL) {
	/* specific to acrord32 version 8 bug */
	sprintf(buf, "[DocOpen(\"%s\")]", fname);
	exec_dde_command(buf, conversation, session);
    }
    sprintf(buf, "[FileOpen(\"%s\")]", fname);
    exec_dde_command(buf, conversation, session);

    sprintf(buf, "[DocGoToNameDest(\"%s\", %s)]", fname, dest);
    err = exec_dde_command(buf, conversation, session);

    free(buf);

    if (conversation) {
	DdeDisconnect(conversation);
    }
    if (session) {
	DdeUninitialize(session);
    }

    return err;
}
Beispiel #8
0
BOOL StartUpDDE ( HWND hWnd )
  {
	extern FARPROC lpDDEProc;
	extern HSZ hSZService;
	extern HSZ hSZItem;
	extern DWORD idInst;
	extern HCONV hConv;

	HMENU hMenu = GetMenu ( hWnd );
	BOOL RtnValue = TRUE;
	UINT Flags = ( MF_BYCOMMAND | MF_ENABLED );

	/*--------------------------------+
	| Setup Client Editor Application |
	+--------------------------------*/

	lpDDEProc = (FARPROC) DDECallBack;

	if ( DdeInitialize ((LPDWORD) &idInst,
							  (PFNCALLBACK)lpDDEProc,
							  APPCMD_CLIENTONLY,0L) )
	  {
		Flags = ( MF_BYCOMMAND | MF_GRAYED);
		RtnValue = FALSE;
		MessageBeep ( 0 );
		MessageBox (NULL,"Can not Initialize DDEML",
		"DDEML ERROR", MB_ICONSTOP | MB_TASKMODAL );
	  }

	else
	  {
		/*----------------------------+
		| Check if CLIPS is available |
		+----------------------------*/

		HSZ hSZTopic = DdeCreateStringHandle ( idInst, "LOAD",    CP_WINANSI );
		hSZItem      = DdeCreateStringHandle ( idInst, "DDEData", CP_WINANSI );
		hSZService   = DdeCreateStringHandle ( idInst, "CLIPS",   CP_WINANSI );

		hConv = DdeConnect ( idInst, hSZService, hSZTopic, (PCONVCONTEXT)NULL);
		if ( hConv == NULL )
		  {
			Flags = ( MF_BYCOMMAND | MF_GRAYED);
			RtnValue = FALSE;
		  }
		else
		  { DdeDisconnect ( hConv ); }
		DdeFreeStringHandle ( idInst, hSZTopic );
	  }

	EnableMenuItem( hMenu, IDM_EDIT_COMPLETE, Flags);
	EnableMenuItem( hMenu, IDM_HELP_COMPLETE, Flags);
	EnableMenuItem( hMenu, IDM_BUFFER_LOAD,   Flags);
	EnableMenuItem( hMenu, IDM_BUFFER_LBUF,   Flags);
	EnableMenuItem( hMenu, IDM_BUFFER_BATCH,  Flags);

	return ( RtnValue );
  }
Beispiel #9
0
void WdeDDEEndConversation( void )
{
    if( WdeClientConv != (HCONV)NULL ) {
        DdeDisconnect( WdeClientConv );
        WdeClientConv = (HCONV)NULL;
    }
    if( WdeServerConv != (HCONV)NULL ) {
        DdeDisconnect( WdeServerConv );
        WdeServerConv = (HCONV)NULL;
    }
    if( hService != (HSZ)NULL ) {
        DdeFreeStringHandle( IdInst, hService );
        hService = (HSZ)NULL;
    }
    if( hTopic != (HSZ)NULL ) {
        DdeFreeStringHandle( IdInst, hTopic );
        hTopic = (HSZ)NULL;
    }
}
Beispiel #10
0
void stop() {
HandleOutput("hel2mos stop-\n");
	if (hConvExtra) {
		DdeDisconnect ( hConvExtra );
	}
	if (idInst) {
		DdeFreeStringHandle ( idInst, hszService );
		DdeFreeStringHandle ( idInst, hszTopic );
		DdeFreeStringHandle ( idInst, hszItem );
	}
}
word
pl_close_dde_conversation(term_t handle)
{ int hdl;

  if ( !get_conv_handle(handle, &hdl) )
    fail;

  DdeDisconnect(conv_handle[hdl]);
  conv_handle[hdl] = (HCONV)NULL;

  succeed;
}
Beispiel #12
0
BOOL ShutDownDDE ( void )
  {
	extern DWORD idInst;
	if ( hConv != NULL)
	  {
		DdeDisconnect ( hConv );
		hConv = NULL;
	  }

	DdeFreeStringHandle ( idInst, hSZService );
	DdeFreeStringHandle ( idInst, hSZItem );
	return (TRUE);
  }
Beispiel #13
0
void ShutDownDDE ( void )
{  extern HSZ hszService, hszItem, hszComplete, hszBatch, hszLoad;
   extern HCONV hConvApp; /* What does this do? -- Apparently Unused */
   extern DWORD idInst;

   if ( hConvApp != NULL)
   {  DdeDisconnect ( hConvApp );
      hConvApp = NULL;
   }
   DdeNameService (idInst, hszService, (HSZ)NULL, DNS_UNREGISTER );
   DdeFreeStringHandle ( idInst, hszService );
   DdeFreeStringHandle ( idInst, hszCommand );
   DdeFreeStringHandle ( idInst, hszResult    );
}
Beispiel #14
0
/****************************************************************************
 *                                                                          *
 *  FUNCTION   : MyDisconnect()                                             *
 *                                                                          *
 *  PURPOSE    : Disconnects the given conversation after updating the      *
 *               associated conversation window.                            *
 *                                                                          *
 *  RETURNS    : TRUE on success, FALSE on failuer.                         *
 *                                                                          *
 ****************************************************************************/
BOOL MyDisconnect(
HCONV hConv)
{
    CONVINFO ci;
    HWND hwnd;
    // before we disconnect, invalidate the associated list window - if
    // applicable.

    ci.cb = sizeof(CONVINFO);
    
    if (DdeQueryConvInfo(hConv, (DWORD)QID_SYNC, &ci) && ci.hConvList &&
            (hwnd = FindListWindow(ci.hConvList)))
        InvalidateRect(hwnd, NULL, TRUE);
    return(DdeDisconnect(hConv));
}
Beispiel #15
0
HDDEDATA gcDDEConnection::disconnect()
{
	m_bConnected = false;

    if (onDisconnect())
	{
		if (DdeDisconnect(m_hConv) == 0)
			 printf("Failed to disconnect from DDE server gracefully");

		delete this;
		return (HDDEDATA)(DWORD)true;
	}

	return (HDDEDATA)(DWORD)false;
}
Beispiel #16
0
void FreeDDE ( void )
  {
	extern FARPROC lpDDEProc;
	extern HCONV hConv;
	extern HSZ hSZService;
	extern HSZ hSZItem;
	extern DWORD idInst;

	if ( hConv != NULL)
	  {
		DdeDisconnect ( hConv );
		hConv = NULL;
	  }

	DdeUninitialize ( idInst );
  }
void Senddde(char* tempstr)
{
  try
  {
    //Connect to the service and request the topic
    if ((hcnv = DdeConnect(idInst, hszService, hszTopic, NULL)) == 0)
    {
      ColorStop();
      return;
    }

    //Start a DDE transaction
    if (DdeClientTransaction((LPBYTE)tempstr, strlen(tempstr)+1,
          hcnv, hszItem, CF_TEXT, XTYP_POKE, 5000, &dwResult) == 0)
    {
      UINT result = DdeGetLastError(idInst);
      switch (result)
      {
        case DMLERR_ADVACKTIMEOUT:
        case DMLERR_BUSY:
        case DMLERR_DATAACKTIMEOUT:
        case DMLERR_DLL_NOT_INITIALIZED:
        case DMLERR_EXECACKTIMEOUT:
        case DMLERR_INVALIDPARAMETER:
        case DMLERR_MEMORY_ERROR:
        case DMLERR_NO_CONV_ESTABLISHED:
        case DMLERR_NO_ERROR:
        case DMLERR_NOTPROCESSED:
        case DMLERR_POKEACKTIMEOUT:
        case DMLERR_POSTMSG_FAILED:
        case DMLERR_REENTRANCY:
        case DMLERR_SERVER_DIED:
        case DMLERR_UNADVACKTIMEOUT:
        default:
          ColorStop();
      }
    }

    //Free DDE
    DdeDisconnect(hcnv);
  }
  catch(...)
  {
    ErrorHandler("Exception thrown in Senddde()!");
  }
}
Beispiel #18
0
/*
 * IEDDEDumpConversation
 */
BOOL IEDDEDumpConversation( HINSTANCE inst )
{
    HCONV       hconv;
    HSZ         hservice;
    HSZ         htopic;
    BOOL        ok;

    ok = IEDDEStart( inst );

    if( ok ) {
        hservice = DdeCreateStringHandle( IdInst, WRE_SERVICE_NAME, CP_WINANSI );
        ok = (hservice != (HSZ)NULL);
    }

    if( ok ) {
        htopic = DdeCreateStringHandle( IdInst, WRE_IMAGE_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 );
    }

    IEDDEEnd();

    if( !ok ) {
        IEDisplayErrorMsg( WIE_DDEINITTITLE, WIE_DDETERMINATIONMSG,
                           MB_OK | MB_ICONINFORMATION );
    }

    return( ok );

} /* IEDDEDumpConversation */
Beispiel #19
0
SleepyApi::Impl::~Impl()
{
	if (m_conv)
	{
		DdeDisconnect(m_conv);
		m_conv=NULL;
	}
	if (m_appId)
	{
		DdeFreeStringHandle(m_appId,m_service);
		DdeFreeStringHandle(m_appId,m_topic);
		DdeFreeStringHandle(m_appId,m_paused);
		
		DdeUninitialize(m_appId);
	}
	assert(m_instance==this);
	m_instance=NULL;
}
Beispiel #20
0
CConv::~CConv()
{
  if(hConv)
   { 
//    char note_remove_msg_box;
//    AfxMessageBox("attempting disconnect");
    DdeDisconnect(hConv);
   }
#ifdef WIN32
  if(ret)
   {        
    DdeFreeDataHandle(ret); //AE:5/22/96 causing GPF under win31. Apparently because these
							//are asynchronous transactions, there really isn't a valid data
							//handle returned.
    ret = NULL;
   }
#endif
}
Beispiel #21
0
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 );
}
Beispiel #22
0
void DDEExecute(const WCHAR* server, const WCHAR* topic, const WCHAR* command)
{
    unsigned long inst = 0;
    HSZ hszServer = NULL, hszTopic = NULL;
    HCONV hconv = NULL;
    HDDEDATA hddedata = NULL;

#ifdef _WIN64
    CrashIf(str::Len(command) >= (DWORD)-1);
    if (str::Len(command) >= (DWORD)-1)
        return;
#endif
    UINT result = DdeInitialize(&inst, &DdeCallback, APPCMD_CLIENTONLY, 0);
    if (result != DMLERR_NO_ERROR)
        goto Exit;
    hszServer = DdeCreateStringHandle(inst, server, CP_WINNEUTRAL);
    if (!hszServer)
        goto Exit;
    hszTopic = DdeCreateStringHandle(inst, topic, CP_WINNEUTRAL);
    if (!hszTopic)
        goto Exit;
    hconv = DdeConnect(inst, hszServer, hszTopic, 0);
    if (!hconv)
        goto Exit;
    DWORD cbLen = ((DWORD)str::Len(command) + 1) * sizeof(WCHAR);
    hddedata = DdeCreateDataHandle(inst, (BYTE*)command, cbLen, 0, 0, CF_UNICODETEXT, 0);
    if (!hddedata)
        goto Exit;

    HDDEDATA answer = DdeClientTransaction((BYTE*)hddedata, (DWORD)-1, hconv, 0, 0, XTYP_EXECUTE, 10000, 0);
    if (answer)
        DdeFreeDataHandle(answer);

Exit:
    if (hddedata)
        DdeFreeDataHandle(hddedata);
    if (hconv)
        DdeDisconnect(hconv);
    if (hszTopic)
        DdeFreeStringHandle(inst, hszTopic);
    if (hszServer)
        DdeFreeStringHandle(inst, hszServer);
    DdeUninitialize(inst);
}
Beispiel #23
0
bool DDEExecute(const WCHAR* server, const WCHAR* topic, const WCHAR* command)
{
    DWORD inst = 0;
    HSZ hszServer = NULL, hszTopic = NULL;
    HCONV hconv = NULL;
    bool ok = false;

    CrashIf(str::Len(command) >= INT_MAX - 1);
    if (str::Len(command) >= INT_MAX - 1)
        return false;

    UINT result = DdeInitialize(&inst, DdeCallback, APPCMD_CLIENTONLY, 0);
    if (result != DMLERR_NO_ERROR)
        return false;

    hszServer = DdeCreateStringHandle(inst, server, CP_WINNEUTRAL);
    if (!hszServer)
        goto Exit;
    hszTopic = DdeCreateStringHandle(inst, topic, CP_WINNEUTRAL);
    if (!hszTopic)
        goto Exit;
    hconv = DdeConnect(inst, hszServer, hszTopic, NULL);
    if (!hconv)
        goto Exit;

    DWORD cbLen = ((DWORD)str::Len(command) + 1) * sizeof(WCHAR);
    HDDEDATA answer = DdeClientTransaction((BYTE *)command, cbLen, hconv, 0, CF_UNICODETEXT, XTYP_EXECUTE, 10000, NULL);
    if (answer) {
        DdeFreeDataHandle(answer);
        ok = true;
    }

Exit:
    if (hconv)
        DdeDisconnect(hconv);
    if (hszTopic)
        DdeFreeStringHandle(inst, hszTopic);
    if (hszServer)
        DdeFreeStringHandle(inst, hszServer);
    DdeUninitialize(inst);

    return ok;
}
Beispiel #24
0
void WEXPORT WClient::disconnect() {
/**********************************/

    WClient *client = (WClient*)WClient::_convMap.findThis( (WHANDLE)_hconv );
    if( client != NULL ) {
        DdeDisconnect( _hconv );
        _convMap.clearThis( this );
        _hconv = NULL;
    }
    if( _service != NULL ) {
        DdeFreeStringHandle( _procid, _service );
        _service = NULL;
    }
    if( _topic != NULL ) {
        DdeFreeStringHandle( _procid, _topic );
        _topic = NULL;
    }
    _connected = false;
}
Beispiel #25
0
Datei: dde.c Projekt: Madzi/POW
BOOL DdeSendCommand (LPSTR service,LPSTR topic,LPSTR command)
{
    DWORD result;
    HCONV hconv;                
    HSZ hservice,htopic;
    BOOL done;

    done=FALSE;
    hservice=DdeCreateStringHandle(ddeInstId,(LPSTR)service,CP_WINANSI);
    htopic=DdeCreateStringHandle(ddeInstId,(LPSTR)topic,CP_WINANSI);

    if (hconv=DdeConnect(ddeInstId,hservice,htopic,0)) {
        if (DdeClientTransaction(command,lstrlen(command)+1,hconv,0,CF_TEXT,XTYP_EXECUTE,10000l,(DWORD FAR *)&result))
            done=TRUE;
        DdeDisconnect(hconv); 
    }
    
    DdeFreeStringHandle(ddeInstId,hservice);
    DdeFreeStringHandle(ddeInstId,htopic);

    return done;
}
BOOL CFileExecutor::DisplayURL(LPCTSTR pszURL)
{
	ShellExecute( AfxGetMainWnd()->GetSafeHwnd(), _T("open"), pszURL, NULL, NULL, SW_SHOWNORMAL );
	return TRUE;

#if 0
	DWORD dwFilterFlags = 0;
	BOOL bSuccess = FALSE;
	DWORD hInstance = 0;

	UINT uiResult = DdeInitialize( &hInstance, DDECallback, dwFilterFlags, 0 );
	if ( uiResult != DMLERR_NO_ERROR ) return FALSE;

	HSZ hszService	= DdeCreateStringHandle( hInstance, L"IExplore", CP_WINUNICODE );
	HSZ hszTopic	= DdeCreateStringHandle( hInstance, L"WWW_OpenURL", CP_WINUNICODE );

	if ( HCONV hConv = DdeConnect( hInstance, hszService, hszTopic, NULL ) )
	{
		CString strCommand;
		USES_CONVERSION;

		strCommand.Format( _T("\"%s\",,0"), pszURL );
		LPCSTR pszCommand = T2CA( (LPCTSTR)strCommand );

		DdeClientTransaction( (LPBYTE)pszCommand, pszCommand,
			 hConv, 0, 0, XTYP_EXECUTE, 4000, NULL );

		DdeDisconnect( hConv );
	}

	DdeFreeStringHandle( hInstance, hszTopic );
	DdeFreeStringHandle( hInstance, hszService );

	DdeUninitialize( hInstance );

	return bSuccess;
#endif
}
Beispiel #27
0
/* Assume dde_initialise has already been called */
BOOL
dde_execute(char *str)
{
HSZ hszServName;
HSZ hszTopicName;
HCONV hConv;
DWORD dwResult = DDE_FNOTPROCESSED;

    /* Make connection to server */
    hszServName = DdeCreateStringHandleA(idInst, (LPSTR)szServiceName, 
	CP_WINANSI);
    hszTopicName = DdeCreateStringHandleA(idInst, (LPSTR)szTopicName, 
	CP_WINANSI);
    hConv = DdeConnect(idInst, hszServName, hszTopicName, (PCONVCONTEXT)NULL);
    if (hConv == NULL) {
	DdeFreeStringHandle(idInst, hszServName);
	DdeFreeStringHandle(idInst, hszTopicName);
	if (debug)
	    gs_addmess("DdeConnect failed\r\n");
	return FALSE;
    }

    /* send command */
    DdeClientTransaction((LPBYTE)str, strlen(str)+1, hConv,
	NULL, CF_TEXT, XTYP_EXECUTE, 10000, &dwResult);

    /* Disconnect from server */
    DdeDisconnect(hConv);
    DdeFreeStringHandle(idInst, hszServName);
    DdeFreeStringHandle(idInst, hszTopicName);
    if (debug) {
	gs_addmess("Sent XTYP_EXECUTE: ");
	gs_addmess(str);
	gs_addmess("\r\n");
    }
    return (dwResult == DDE_FACK);
}
Beispiel #28
0
int
main (int argc, char *argv[])
{
  DWORD idDde = 0;
  HCONV HConversation;
  HSZ   Server;
  HSZ   Topic = 0;
  char  command[1024];

  if (argc < 2)
    {
      fprintf (stderr, "usage: ddeclient server [topic]\n");
      exit (1);
    }

  DdeInitialize (&idDde, (PFNCALLBACK)DdeCallback, APPCMD_CLIENTONLY, 0);

  Server = DdeCreateStringHandle (idDde, argv[1], CP_WINANSI);
  if (argc > 2)
    Topic = DdeCreateStringHandle (idDde, argv[2], CP_WINANSI);

  HConversation = DdeConnect (idDde, Server, Topic, NULL);
  if (HConversation != 0)
    {
      while (fgets (command, sizeof(command), stdin) != NULL)
	DdeCommand (command);

      DdeDisconnect (HConversation);
    }

  DdeFreeStringHandle (idDde, Server);
  if (Topic)
    DdeFreeStringHandle (idDde, Topic);
  DdeUninitialize (idDde);

  return (0);
}
Beispiel #29
0
int
gsview_progman(char *groupname, char *gsviewpath, int gsver, char *gspath, char *gsargs)
{
DWORD idInst = 0L;
FARPROC lpDdeProc;
HSZ hszServName;
HSZ hszSysTopic;
HSZ hszGroupsItem;
HCONV hConv;
HDDEDATA hdata = NULL;
char setup[MAXSTR+MAXSTR];
DWORD dwResult;
char groupfile[MAXSTR];
int i;
char *s, *d;
FILE *ddefile;
char gspathbuf[MAXSTR];
char gsviewpathbuf[MAXSTR];
char gsdocbuf[MAXSTR];

    strncpy(gspathbuf, gspath, sizeof(gspathbuf)/sizeof(TCHAR));
    strncpy(gsdocbuf, gsargs, sizeof(gsdocbuf)/sizeof(TCHAR));
    d = strchr(gsdocbuf, ';');
    if (d)
       *d = '\0';
    if (gsver >= 593) {
	d = strrchr(gsdocbuf, '\\');
	if (d) {
	    d++;
	    strcpy(d, "doc\\");
	}
    }
    else {
	strcat(gsdocbuf, "\\");
    }
    strncpy(gsviewpathbuf, gsviewpath, sizeof(gsviewpathbuf));
    if (!is_win32s) {
	/* The DDE interface isn't reliable with long names */
	/* Convert everything to short names */
	GetShortPathNameA(gspath, gspathbuf, sizeof(gspathbuf));
	GetShortPathNameA(gsviewpath, gsviewpathbuf, sizeof(gsviewpathbuf));
    }

    /* Open ProgMan DDE undo file if it doesn't exist */
    strcpy(setup, gsviewpathbuf);
    strcat(setup, GSVIEW_ZIP);
    d = strrchr(setup, '.');
    strcpy(d, "dde.log");
    ddefile = fopen(setup, "r");
    if (ddefile != (FILE *)NULL) {
	/* We found a previous ProgMan DDE undo file. */
	/* Don't touch it since we want to keep the original record */
	/* of the ProgMan state before GSview was installed */ 
	fclose(ddefile);
	ddefile = (FILE *)NULL;
    }
    else {
        ddefile = fopen(setup, "w");
	/* If we fail to open the file for writing, the destination is probably 
	 * read only.  Don't worry, just don't write to the log file.
	 */
    }

    /* derive group filename from group name */
    for (i=0, s=groupname, d=groupfile; i<8 && *s; s++) {
	if (isalpha((int)(*s)) || isdigit((int)(*s))) {
	    *d++ = *s;
	    i++;
	} 
    }
    *d = '\0';
    if (strlen(groupfile)==0)
	strcpy(groupfile, "gstools");

    lpDdeProc = MakeProcInstance((FARPROC)DdeCallback, phInstance);
    if (DdeInitialize(&idInst, (PFNCALLBACK)lpDdeProc, CBF_FAIL_POKES, 0L)) {
	return 1;
    }
    hszServName = DdeCreateStringHandleA(idInst, "PROGMAN", CP_WINANSI);
    hszSysTopic = DdeCreateStringHandleA(idInst, "PROGMAN", CP_WINANSI);
    hConv = DdeConnect(idInst, hszServName, hszSysTopic, (PCONVCONTEXT)NULL);
    if (hConv == NULL) {
	DdeFreeStringHandle(idInst, hszServName);
	DdeFreeStringHandle(idInst, hszSysTopic);
	return 1;
    }

    if (ddefile) {
	/* Find out if group existed */
	hszGroupsItem = DdeCreateStringHandleA(idInst, groupname, CP_WINANSI);
	hdata = DdeClientTransaction((LPBYTE)NULL, 0, hConv,\
	    hszGroupsItem, CF_TEXT, XTYP_REQUEST, 5000, &dwResult);
	DdeFreeStringHandle(idInst, hszGroupsItem);
    }

#define DDEEXECUTE(str)\
    DdeClientTransaction((LPBYTE)str, strlen(str)+1, hConv,\
	NULL, CF_TEXT, XTYP_EXECUTE, 5000, &dwResult)

    sprintf(setup, "[CreateGroup(\042%s\042,%s.grp)][ShowGroup(\042%s\042,1)]",
	groupname, groupfile, groupname);  /* display, active */
    DDEEXECUTE(setup);
    if (ddefile)	/* display, no active */
        fprintf(ddefile, "[ShowGroup(\042%s\042,8)]\n",groupname);
    sprintf(setup, "[ReplaceItem(\042%s\042)]", GSVIEW_NAME);
    DDEEXECUTE(setup);
#ifdef _WIN64
#define GSVIEW_ICON "gsview64.ico"
#else
#define GSVIEW_ICON "gsview32.ico"
#endif
    if (!is_win4)
       sprintf(setup, "[AddItem(\042%s%s\042,\042%s\042, \042%s%s\042)]", 
	  gsviewpathbuf, GSVIEW_EXENAME, GSVIEW_NAME, gsviewpathbuf, 
	  GSVIEW_ICON);
    else
       sprintf(setup, "[AddItem(\042%s%s\042,\042%s\042)]", 
	  gsviewpathbuf, GSVIEW_EXENAME, GSVIEW_NAME);
    DDEEXECUTE(setup);
    if (ddefile)
        fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", GSVIEW_NAME);

/* Win3.1 documentation says you must put quotes around names */
/* with embedded spaces. */
/* In Win95, it appears you must put quotes around the EXE name */
/* and options separately */

    sprintf(setup, "[ReplaceItem(\042GSview README\042)]");
    DDEEXECUTE(setup);
#ifdef NOTUSED_IN_GSVIEW28
    if (!is_win4)
	sprintf(setup, "[AddItem(\042notepad.exe %sREADME.TXT\042,\042GSview README\042)]", 
	    gsviewpathbuf);
    else
	sprintf(setup, "[AddItem(\042notepad.exe\042 \042%sREADME.TXT\042,\042GSview README\042,\042notepad.exe\042,1)]", 
	    gsviewpathbuf);
#endif
    sprintf(setup, "[AddItem(\042%sReadme.htm\042,\042GSview README\042)]", 
	    gsviewpathbuf);
    DDEEXECUTE(setup);
    if (ddefile)
        fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", "GSview README");

    sprintf(setup, "[ReplaceItem(\042Ghostscript\042)]");
    DDEEXECUTE(setup);
    if (!is_win4)
        sprintf(setup, "[AddItem(\042%s%s -I%s\042,\042Ghostscript\042, \042%sgstext.ico\042)]", 
	    gspathbuf, GS_EXENAME, gsargs, gspathbuf);
    else
        sprintf(setup, "[AddItem(\042%s%s\042 \042-I%s\042,\042Ghostscript\042)]", 
	    gspathbuf, GS_EXENAME, gsargs);
    DDEEXECUTE(setup);
    if (ddefile)
        fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", "Ghostscript");

    sprintf(setup, "[ReplaceItem(\042Ghostscript README\042)]");
    DDEEXECUTE(setup);
    if (gsver >= 540) {
	    sprintf(setup, 
		"[AddItem(\042%sReadme.htm\042,\042Ghostscript README\042)]", 
		 gsdocbuf);
    }
    else {
	if (!is_win4)
	    sprintf(setup, "[AddItem(\042notepad.exe %sREADME.\042,\042Ghostscript README\042)]", 
		 gsdocbuf);
	else
	    sprintf(setup, "[AddItem(\042notepad.exe\042 \042%sREADME.\042,\042Ghostscript README\042, \042notepad.exe\042,1)]", 
		 gsdocbuf);
    }
    DDEEXECUTE(setup);
    if (ddefile)
        fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", "Ghostscript README");


#undef DDEXECUTE

    /* Now remember the way things were */
    if (ddefile) {
      if (hdata) {
	DWORD dlen;
	BYTE FAR *lpData = DdeAccessData(hdata, &dlen);
	LPSTR p, q;
	/* skip first line */
	q = (LPSTR)lpData;
	while (*q && (*q != '\r') && (*q != '\n'))
	    q++;
	while (*q && ((*q == '\r') || (*q == '\n')))
	    q++;
	p = q;
	/* for each group item */
	while (*p) {
	    /* skip to end of line */
	    while (*q && (*q != '\r') && (*q != '\n'))
		q++;
	    strncpy(setup, p, (int)(q-p)+1);
	    add_group_item(ddefile, setup);
	    /* skip to start of next group name */
	    while (*q && ((*q == '\r') || (*q == '\n')))
		q++;
	    p = q;
	}
	if (ddefile)		/* display, no active */
	    fprintf(ddefile, "[ShowGroup(\042%s\042,8)]\n",groupname);
	DdeUnaccessData(hdata);
	DdeFreeDataHandle(hdata);
      }
      else {
	/* group didn't exist before, so delete it */
        fprintf(ddefile, "[DeleteGroup(\042%s\042)]\n", groupname);
      }
      fclose(ddefile);
    }

    DdeDisconnect(hConv);
    DdeFreeStringHandle(idInst, hszServName);
    DdeFreeStringHandle(idInst, hszSysTopic);
    DdeUninitialize(idInst);

    return 0;
}
Beispiel #30
0
/*****************************************************************
 *            DdeDisconnect   (DDEML.8)
 */
BOOL16 WINAPI DdeDisconnect16(HCONV hConv)
{
    return (BOOL16)DdeDisconnect(hConv);
}