dde回调函数不起作用

时间:2013-03-06 10:03:37

标签: dde

问题在于:
我写了一个程序来接收StockClient的数据 当我使用DDESpy时,我可以看到诸如

之类的消息
Time:xxxx hwndTo=0xe00b0 Message(Posted)=Data:<br>
 hwndFrom=0x1f06dc, status=2000(fRelease ) fmt=0x1("CF_TEXT")<br>
 Data=          "value"<br>
 Item=          "xxxxx"<br>

但我的ddecallback功能不起作用(偶尔它可以工作),为什么?

DdeInitialize( &_dde_inst, dde_callback, APPCMD_CLIENTONLY/*|CBF_FAIL_ALLSVRXACTIONS*/, 0 ); HSZ _server = DdeCreateStringHandle ( _dde_inst, "DDEServer", CP_WINANSI ); if( !_server ) return -1;

HSZ _topic = DdeCreateStringHandle( _dde_inst, "TOPIC1", CP_WINANSI );
HCONV _conv = DdeConnect( _dde_inst, _server, _topic, NULL );
if( !_conv )
    return -1;

for( int i = 0; i < ITEM_NUM; ++i )
{
    HSZ _item = DdeCreateStringHandle( _dde_inst, _list[i], CP_WINANSI );
    if( _item )
    {
        DWORD _result;
        HDDEDATA _data = DdeClientTransaction( NULL, NULL, _conv, _item, CF_TEXT, XTYP_ADVSTART, TIMEOUT_ASYNC, &_result );
        UINT _error = DdeGetLastError(_dde_inst );
        DdeFreeStringHandle( _dde_inst, _item );
        int _reserve = DMLERR_NO_ERROR;
        if( _error != 0 )
        {
            fprintf( stdout, "dde error = %d\n", _error );
            continue;
        }
    }
}

0 个答案:

没有答案