示例#1
0
CDDEConnection *CDDEClient::MakeConnection(const CString& /* host */, const CString& server_name, const CString& topic)
{
    HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (const char *)server_name, CP_WINANSI);
    HSZ topic_atom = DdeCreateStringHandle(DDEIdInst, (const char *)topic, CP_WINANSI);

    HCONV hConv = DdeConnect(DDEIdInst, serviceName, topic_atom, (PCONVCONTEXT)NULL);
    BOOL rt = DdeFreeStringHandle(DDEIdInst, serviceName);
    rt = DdeFreeStringHandle(DDEIdInst, topic_atom);
    if (hConv == NULL)
        return NULL;
    else
    {
        CDDEConnection *connection = OnMakeConnection();
        if (connection)
        {
            connection->hConv = hConv;
            connection->topic_name = topic;
            connection->client = this;
            connections.AddTail(connection);
//	  bDisconnected = true;
            return connection;
        }
        else return NULL;
    }
}
示例#2
0
文件: dde.c 项目: jamesdlow/jni2dde
//Connect to DDE Server
int connectDDE(char* ServiceName, char* TopicName)
{

    //DDE requires special handles to Strings
    HSZ ServiceHSZ = DdeCreateStringHandle(Inst, ServiceName, 0);
    HSZ TopicHSZ = DdeCreateStringHandle(Inst, TopicName, 0);

    //Setup the connection between DDE client and server
    Conversation = DdeConnect(Inst, ServiceHSZ, TopicHSZ, NULL);

    DdeFreeStringHandle(Inst, ServiceHSZ);
    DdeFreeStringHandle(Inst, TopicHSZ);

    //If we recieve a handle then connection atempt was sucessul
    if (Conversation == NULL)
    {
        printf("Failed to Connect to DDE Server. Instance %d \n", Inst);
        DDEError(DdeGetLastError(Inst));
        return 1;
    }
    else
    {
        #ifdef _ddedebug
        printf("Connected DDE\n");
        #endif
        return 0;
    }
}
示例#3
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;
}
示例#4
0
HRESULT DDEService::_RegisterDDE()
{
    HRESULT hr = E_FAIL;

    m_hszProgman = DdeCreateStringHandle(m_dwDDEInst, _T("PROGMAN"), DDE_CP);
    if (m_hszProgman != 0L)
    {
        m_hszGroups = DdeCreateStringHandle(m_dwDDEInst, _T("Groups"), DDE_CP);
        if (m_hszGroups != 0L)
        {
            m_hszFolders = DdeCreateStringHandle(m_dwDDEInst, _T("Folders"), DDE_CP);
            if (m_hszFolders != 0L)
            {
                m_hszAppProperties = DdeCreateStringHandle(m_dwDDEInst, _T("AppProperties"), DDE_CP);
                if (m_hszAppProperties != 0L)
                {
                    if (DdeNameService(m_dwDDEInst, m_hszProgman, 0L, DNS_REGISTER) != 0L)
                    {
                        if (DdeNameService(m_dwDDEInst, m_hszFolders, 0L, DNS_REGISTER) != 0L)
                        {
                            hr = S_OK;
                        }
                    }
                }
            }
        }
    }

    return hr;
}
示例#5
0
bool WdeDDEStartConversation( void )
{
    if( IdInst == 0 ) {
        return( FALSE );
    }

    hService = DdeCreateStringHandle( IdInst, WRE_SERVICE_NAME, CP_WINANSI );
    if( hService == (HSZ)NULL ) {
        return( FALSE );
    }

    hTopic = DdeCreateStringHandle( IdInst, WRE_DIALOG_TOPIC, CP_WINANSI );
    if( hTopic == (HSZ)NULL ) {
        return( FALSE );
    }

    WdeClientConv = DdeConnect( IdInst, hService, hTopic, (LPVOID)NULL );
    if( WdeClientConv == (HCONV)NULL ) {
        return( FALSE );
    }

    if( !WdeStartDDEEditSession() ) {
        return( FALSE );
    }

    return( TRUE );
}
示例#6
0
HDDEDATA CALLBACK DdeCallback(
    UINT uType,     // Transaction type.
    UINT uFmt,      // Clipboard data format.
    HCONV hconv,    // Handle to the conversation.
    HSZ hsz1,       // Handle to a string.
    HSZ hsz2,       // Handle to a string.
    HDDEDATA hdata, // Handle to a global memory object.
    DWORD dwData1,  // Transaction-specific data.
    DWORD dwData2)  // Transaction-specific data.
{
	if(uType==XTYP_ADVDATA && uFmt==CF_TEXT)
    {
        HSZ hszItem1 = DdeCreateStringHandle(idInst, szItem1, 0);
        HSZ hszItem2 = DdeCreateStringHandle(idInst, szItem2, 0);
        char szResult[255];
        if((!DdeCmpStringHandles(hsz1, hszTopic)) && (!DdeCmpStringHandles(hsz2, hszItem1)))
        {
            DdeGetData(hdata, (unsigned char *)szResult, 255, 0);
            printf("%s - %s\n", szItem1,szResult);
        }
        else if((!DdeCmpStringHandles(hsz1, hszTopic)) && (!DdeCmpStringHandles(hsz2, hszItem2)))
        {
            DdeGetData(hdata, (unsigned char *)szResult, 255, 0);
            printf("%s - %s\n", szItem2,szResult);
        }
    }
    return 0;
}
示例#7
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 );
  }
示例#8
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 );
}
示例#9
0
static DWORD open_dde_conversation (LPCTSTR topic_name,
				    const char *exename,
				    const char *ddename,
				    HCONV *convp)
{
    DWORD session = 0;
    HCONV conversation = NULL;
    HSZ service, topic;
    UINT ret;
    int i, err = 0;
    
    ret = DdeInitialize(&session, (PFNCALLBACK) init_callback,
			APPCLASS_STANDARD | APPCMD_CLIENTONLY, 0);
    
    if (ret != DMLERR_NO_ERROR) {
	fprintf(stderr, "DDE: couldn't initialize session\n");
	return 0;
    }

    service = DdeCreateStringHandle(session, ddename, CP_WINANSI);
    topic   = DdeCreateStringHandle(session, topic_name, CP_WINANSI);

    if (!service || !topic) {
	fprintf(stderr, "DDE: string creation failed\n");
	DdeUninitialize(session);
	return 0;
    }
    
    conversation = DdeConnect(session, service, topic, 0);

    if (conversation == NULL) {
	err = start_dde_server(exename);
	if (!err) {
	    /* try to connect */
	    for (i=0; i<5 && !conversation; i++) {
		Sleep(CONNECT_DELAY);
		conversation = DdeConnect(session, service, topic, 0);
	    }
	}
	if (conversation == NULL && !err) {
	    fprintf(stderr, "DDE: couldn't contact server %s\n", ddename);
	    err = 1;
	}	
    }

    DdeFreeStringHandle(session, service);
    DdeFreeStringHandle(session, topic);

    if (err) {
	DdeUninitialize(session);
	session = 0;
    } else {
	*convp = conversation;
    }

    return session;
}
示例#10
0
bool WEXPORT WClient::connect( const char *service, const char *topic ) {
/***********************************************************************/

    _service = DdeCreateStringHandle( _procid, (char *)service, CP_WINANSI );
    _topic = DdeCreateStringHandle( _procid, (char *)topic, CP_WINANSI );
    _hconv = DdeConnect( _procid, _service, _topic, NULL );
    if( _hconv != NULL ) {
        _convMap.setThis( this, (WHANDLE)_hconv );
        _connected = true;
        return( true );
    }
    DdeGetLastError( _procid );
    return( false );
}
示例#11
0
BOOL PEXPORT KppDDEPostAdvise(ATOMID idObjName, ATOMID idSlot)
{
    OBJECTID idLink = FindLink(LinkName(idObjName, idSlot));
    
    if (idLink)
    {
        ATOMID idTopic = Kpp_Get_SlotValue(OBJECT, idLink, Slot(idTopic));
        HSZ hszTopic = AtomToHsz(idTopic);
        WORD wLen = KppGetAtomName(idObjName, return_buffer, RET_BUFFER_LEN);
        BOOL bRes = FALSE;
        HSZ hszItem;
        
        return_buffer[wLen++] = ':';
        KppGetAtomName(idSlot, return_buffer + wLen, RET_BUFFER_LEN - wLen);
        hszItem = DdeCreateStringHandle(dwDDEInst, return_buffer, CP_WINANSI);
        
        if (hszTopic && hszItem)
            bRes = DdePostAdvise(dwDDEInst, hszTopic, hszItem);
        
        DdeFreeStringHandle(dwDDEInst, hszTopic);
        DdeFreeStringHandle(dwDDEInst, hszItem);

        return bRes;
    }
    
    return FALSE;
}
示例#12
0
// Atom table stuff
static HSZ DDEAddAtom(const CString& string)
{
    HSZ atom = DdeCreateStringHandle(DDEIdInst, (const char *)string, CP_WINANSI);
//  DDEAtomTable.Append(string, (CObject *)atom);
    DDEAtomTable.SetAt(string, (CObject *)atom);
    return atom;
}
示例#13
0
/*
 * CreateStringHandle - build a kept string handle
 */
bool CreateStringHandle( const char *name, HSZ *hdl )
{
    hsz_list    *hlptr;
    int         len;
    HSZ         ohdl;
    char        buff[256];

    if( hdl == NULL ) {
        hdl = &ohdl;
    }
    len = strlen( name );
    if( len > 255 )
        len = 255;
    memcpy( buff, name, len );
    buff[len] = '\0';
    *hdl = DdeCreateStringHandle( DDEInstId, buff, 0 );
    if( *hdl == 0 ) {
        return( false );
    }
    if( !DdeKeepStringHandle( DDEInstId, *hdl ) ) {
        return( false );
    }
    hlptr = MemAlloc( offsetof( hsz_list, string ) + len + 1 );

    hlptr->hsz = *hdl;
    memcpy( hlptr->string, buff, len + 1 );
    AddLLItemAtEnd( (ss **)&hszHead, (ss **)&hszTail, (ss *)hlptr );
    return( true );

} /* CreateStringHandle */
示例#14
0
/*
 * CreateStringHandle - build a kept string handle
 */
bool CreateStringHandle( char *name, HSZ *hdl )
{
    hsz_list    *hlptr;
    int         len;
    HSZ         ohdl;

    if( hdl == NULL ) {
        hdl = &ohdl;
    }

    *hdl = DdeCreateStringHandle( DDEInstId, name, 0 );
    if( *hdl == 0 ) {
        return( FALSE );
    }
    if( !DdeKeepStringHandle( DDEInstId, *hdl ) ) {
        return( FALSE );
    }
    len = strlen( name );
    hlptr = MemAlloc( offsetof( hsz_list, string ) + len + 1 );

    hlptr->hsz = *hdl;
    memcpy( hlptr->string, name, len + 1 );
    AddLLItemAtEnd( (ss **)&hszHead, (ss **)&hszTail, (ss *)hlptr );
    return( TRUE );

} /* CreateStringHandle */
/***************************************************************************
	Connect & Disconnect
****************************************************************************/
void	DDEIntegratorClient::SetClientTopic	( char* pszTopicName )
{
	if ( m_hszClientTopic )
		DdeFreeStringHandle( gDDEClientId, m_hszClientTopic);
	m_hszClientTopic =
			DdeCreateStringHandle( gDDEClientId, (LPSTR)pszTopicName, CP_WINANSI );
}
示例#16
0
文件: POWDDE.C 项目: Madzi/POW
void FAR InitDDE (HWND powinstance)
{
    ddeProc=MakeProcInstance((FARPROC)PowDdeServerProc,hInst);
    ddeInstId=0;             
    
    // use window handle as topic to make it possible
    // to call specific instances of pow!
    wsprintf((LPSTR)topic,"%04X",powinstance);
                                    
    if (DdeInitialize((LPDWORD)&ddeInstId,(PFNCALLBACK)ddeProc,APPCLASS_STANDARD,0)==DMLERR_NO_ERROR) {
        ddeInstalled=TRUE;
        hService=DdeCreateStringHandle(ddeInstId,"pow",CP_WINANSI);
        hTopic=DdeCreateStringHandle(ddeInstId,(LPSTR)topic,CP_WINANSI);
        DdeNameService(ddeInstId,hService,0,DNS_REGISTER);
    }    
}
示例#17
0
文件: clipsdde.c 项目: atrniv/CLIPS
BOOL StartUpDDE(void)
  {
   if (DdeInitialize(&idInst, 
                     (PFNCALLBACK) DDECallBack,
                     APPCLASS_STANDARD,
                     0) != DMLERR_NO_ERROR)
     { return(FALSE); }
  
   hszService  = DdeCreateStringHandle(idInst,"CLIPS",CP_WINANSI );
   hszCommand  = DdeCreateStringHandle(idInst,"COMMAND",CP_WINANSI );
   hszResult   = DdeCreateStringHandle(idInst,"RESULT",CP_WINANSI );
   
   if (! DdeNameService(idInst,hszService,0L,DNS_REGISTER))
     { return(FALSE); }
   
   return(TRUE);
  }
示例#18
0
void DDEPoke(DWORD idInst, HCONV hConv, char* szItem, char* szData)
{
    HSZ hszItem = DdeCreateStringHandle(idInst, szItem, 0);
	DdeClientTransaction((LPBYTE)szData, (DWORD)(lstrlen(szData)+1),
                          hConv, hszItem, CF_TEXT,
                          XTYP_POKE, 3000, NULL);
    DdeFreeStringHandle(idInst, hszItem);
}
示例#19
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 */
示例#20
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);
}
示例#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 );
}
示例#22
0
文件: POWDDE.C 项目: Madzi/POW
int IsEqualString (HSZ hsz,LPSTR lp)
{
    HSZ h;
    int ret;
    
    h=DdeCreateStringHandle(ddeInstId,lp,CP_WINANSI);
    ret=(DdeCmpStringHandles(hsz,h)==0);
    DdeFreeStringHandle(ddeInstId,h);
    return ret;
}
示例#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;
}
示例#24
0
文件: ms1.cpp 项目: nrnhines/nrn
int start() {
HandleOutput("hel2mos start-\n");
	if (!idInst) {
		MessageBox(NULL, "idInst is 0", "ochelp start", MB_OK);
		return 0;
	}
		hszService = DdeCreateStringHandle ( idInst, "NETSCAPE", CP_WINANSI );
		hszTopic = DdeCreateStringHandle ( idInst, "WWW_OpenURL", CP_WINANSI );
		hszItem = DdeCreateStringHandle ( idInst, "NetscapeData", CP_WINANSI );
		hConvExtra = DdeConnect ( idInst, hszService, hszTopic,
					(PCONVCONTEXT) NULL );
		if (!hConvExtra) {
			MessageBox(NULL, "Conversation not established with NETSCAPE",
				"ochelp start", MB_OK);
			return 0;
		}
HandleOutput("Conversation established with NETSCAPE\n");
		return 1;
}
示例#25
0
bool DDE::RegisterDDE()
{
	// Startup DDE library
	UINT result = DdeInitialize(&g_pidInst, (PFNCALLBACK) &DdeCallback, 0, 0);
	if(result != DMLERR_NO_ERROR) {
		Log::Error("Unable to initialize DDE: %d", result);
		return false;
	}

	// Check for app/topic override
	char* appName = iniparser_getstr(g_ini, DDE_SERVER_NAME);
	char* topic = iniparser_getstr(g_ini, DDE_TOPIC);

	g_serverName = DdeCreateStringHandle(g_pidInst, appName == NULL ? "WinRun4J" : appName, CP_WINANSI);
	g_topic = DdeCreateStringHandle(g_pidInst, topic == NULL ? "system" : topic, CP_WINANSI);

	// Register the server
	DdeNameService(g_pidInst, g_serverName, NULL, DNS_REGISTER);
	return true;
}
示例#26
0
CDDEServer::~CDDEServer(void)
{
    if (service_name != "")
    {
        HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (const char *)service_name, CP_WINANSI);
        if (DdeNameService(DDEIdInst, serviceName, NULL, DNS_UNREGISTER) == 0)
        {
            DDEPrintError();
        }
    }
}
示例#27
0
WEXPORT WServer::WServer( const char *service, const char *topic, WObject* owner, sbc notify )
        : _procid( 0 )
        , _service( 0 )
        , _topic( 0 )
        , _ok( false ) {
/**********************/

    if( _server == NULL ) {
        _server = this;
        _owner = owner;
        _notify = notify;
        _procInst = MakeProcInstance( (FARPROC)serverCallback, GUIMainHInst );
        if( !DdeInitialize( &_procid, (PFNCALLBACK)_procInst, INITFLAGS, 0L ) ) {
            _service = DdeCreateStringHandle( _procid, (char *)service, CP_WINANSI );
            _topic = DdeCreateStringHandle( _procid, (char *)topic, CP_WINANSI );
            if( DdeNameService( _procid, _service, 0, DNS_REGISTER ) ) {
                _ok = true;
            }
        }
    }
}
示例#28
0
BOOL CDDEServer::Create(const CString& server_name)
{
    service_name = server_name;
    HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (const char *)server_name, CP_WINANSI);

    if (DdeNameService(DDEIdInst, serviceName, NULL, DNS_REGISTER) == 0)
    {
        DDEPrintError();
        return FALSE;
    }
    return TRUE;
}
示例#29
0
文件: dde.c 项目: 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;
}
示例#30
0
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
}