Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cannot get 2 DDE links working under Win XP

7 views
Skip to first unread message

Totew

unread,
Jan 15, 2010, 7:06:00 AM1/15/10
to
My C++ Program1 gets DDE data from Application1. When this pair
working alone everything is fine. Now I'm writing Program2 which
should get DDE data from Application2 the same way Program1 does with
Application1. Problem is when Program2 starts it halts DDE export from
Application1 to Program1. I changed "EXDDE" to "EXDDE2" in m_Sservice
= DdeCreateStringHandle(m_inst,"EXDDE",CP_WINANSI) for my Program2. It
does't help. As far as I can see problem is Windows (XP SP3)
initialize Program2

DdeInitialize(&m_inst, exitFunction, MF_CALLBACKS|MF_CONV|MF_ERRORS|
MF_HSZ_INFO|MF_LINKS|MF_POSTMSGS|MF_SENDMSGS,0);

with the same m_inst as the Program1. So some conflict occures and DDE
data halts for the both programs. Even if I execute Program2 while
running Program1 with no Application1&Application2 running (hence no
DDE data coming at all). Program2 halts when executing
DdeCreateStringHandle(m_inst,"EXDDE",CP_WINANSI);

Both Program1 and Program2 use the same piece of code for getting DDE
data except for
m_Sservice = DdeCreateStringHandle(m_inst,"EXDDE",CP_WINANSI)
changed for
m_Sservice = DdeCreateStringHandle(m_inst,"EXDDE2",CP_WINANSI)

dde.h:
#define MAXSIZE 64000
#pragma once

#include <stdio.h>
#include "windows.h"
#include "stdio.h"
#include "ddeml.h"

#pragma warning(disable : 4996)

class CExDDE
{

HSZ m_Sservice;

public:
static DWORD m_inst;
static char m_ItemData1[256];
static char m_ItemData2[256];

static void getVal(void * val, unsigned char ** pos, int size);

public:

CExDDE();
~CExDDE();
};


----------------------------------------------------------------

dde.cpp :
#include "stdafx.h"

#include "dde.h"
HDDEDATA CALLBACK exitFunction(UINT uType,UINT uFmt, HCONV hconv,HSZ
hsz1,HSZ hsz2,HDDEDATA hdata,DWORD dwData1,DWORD dwData2);

extern HWND g_hWndMain;

CExDDE::CExDDE()
{
m_inst = 0;

DdeInitialize(&m_inst, exitFunction,MF_CALLBACKS|MF_CONV|MF_ERRORS|
MF_HSZ_INFO|MF_LINKS|MF_POSTMSGS|MF_SENDMSGS,0);

m_Sservice = DdeCreateStringHandle(m_inst,"EXDDE",CP_WINANSI);
DdeNameService(m_inst,m_Sservice,0,DNS_REGISTER);
//printf("reg=%d\n",DdeGetLastError(m_inst));

}

CExDDE::~CExDDE()
{
DdeNameService(m_inst,m_Sservice,0,DNS_UNREGISTER);
DdeFreeStringHandle(m_inst,m_Sservice);

DdeUninitialize(m_inst);
}

DWORD CExDDE::m_inst = 0;
char CExDDE::m_ItemData1[256];
char CExDDE::m_ItemData2[256];

void CExDDE::getVal(void * val, unsigned char ** pos, int size)
{
memcpy(val, (*pos), size);
(*pos) += size;
}
struct SDdeQueItem
{
unsigned char data[MAXSIZE];
int size;
char sTopic[256];
char sCells[256];
} ;

HDDEDATA CALLBACK exitFunction(UINT uType,UINT uFmt, HCONV
hconv,HSZ hsz1,HSZ hsz2,HDDEDATA hdata,DWORD dwData1,DWORD dwData2)
// .
{char forTopic[256] = "", forItem[256] = "", forData[256] = "",
forWho[256] = "";

switch (uType & XCLASS_MASK)
{case XCLASS_BOOL : // .
switch (uType)
......................................................................
......................................................................


------------------------------------------------------------------------------------------------

main.cpp :
#include "dde.h"

..................

CExDDE * pDde;

..................

pDde = new CExDDE();

What should I change so that both Program1 and Program2 could ran
simultaneously?


Thank you for your help!

0 new messages