MFC DDE开发中令人迷惑的问题?

探讨MFC(ddeml)开发环境下DDE在时钟函数与线程中的不同表现,时钟函数正常工作而相同代码在独立线程中却触发错误。问题可能涉及数据句柄初始化、会话句柄使用或数据句柄释放等方面。

在用MFC(ddeml)开发DDE中,遇到一个令人迷惑的问题, ddeml提供的一些命令,在时钟函数里或按钮事件里运行正常,可是在线程里运行就出现如下错误:

"A parameter failed to be validated by the DDEML."

下面是两段代码:

//时钟
void YD::TimerProc(long hwnd,long nIDEvent,long uElapse,long lpTimerFunc)
{
      CString strData;
   static AAAA=0;  
      if (AAA.G_connection )
   {
  strData.Format("T%d", AAAA++);
        AAA.G_connection->Advise("aaa",(char *)(const char *)strData);
 }
}

//线程
UINT YD::YFDDE(LPVOID pParam)
{
    CString strData;
 static AAAA=0;

  while(1)
  {
 if (AAA.G_connection )
 {
  strData.Format("%d", AAAA++);
        AAA.G_connection->Advise("aaa",(char *)(const char *)strData);

  Sleep(3000);       
 } 
  
  }
  return 0;
}

线程和时钟的代码完全一样,可是运行结果不一样,难到ddlml有特殊的限制?这是MSDN说明的理由:

The application used a data handle initialized with a different item name handle than was required by the transaction.

The application used a data handle that was initialized with a different clipboard data format than was required by the transaction.

The application used a client-side conversation handle with a server-side function or vice versa.

The application used a freed data handle or string handle.

More than one instance of the application used the same object.

我也没有弄明白什么意思。

对了,有谁知道侯捷老师的《Windows DDE 动态资料交换》电子版图书在哪里下载?




评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值