DdePostAdvise

3.1

  #include <ddeml.h>    

  BOOL DdePostAdvise(idInst, hszTopic, hszItem)    
  DWORD idInst; /* instance identifier, */  
  HSZ hszTopic; /* handle of topic-name string */
  HSZ hszItem; /* handle of item-name string */

The DdePostAdvise function causes the system to send an XTYP_ADVREQ transaction to the calling (server) application's dynamic data exchange (DDE) callback function for each client that has an advise loop active on the specified topic or item name pair. A server application should call this function whenever the data associated with the topic or item name pair changes.

Parameters

idInst

Specifies the application-instance identifier obtained by a previous call to the DdeInitialize function.

hszTopic

Identifies a string that specifies the topic name. To send notifications for all topics with active advise loops, an application can set this parameter to NULL.

hszItem

Identifies a string that specifies the item name. To send notifications for all items with active advise loops, an application can set this parameter to NULL.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Errors

Use the DdeGetLastError function to retrieve the error value, which may be one of the following:

DMLERR_DLL_NOT_INITIALIZED
DMLERR_DLL_USAGE
DMLERR_NO_ERROR

Comments

A server that has nonenumerable topics or items should set the hszTopic and hszItem parameters to NULL so that the system will generate transactions for all active advise loops. The server's DDE callback function returns NULL for any advise loops that do not need to be updated.

If a server calls DdePostAdvise with a topic/item/format name set that includes the set currently being handled in a XTYP_ADVREQ callback, a stack overflow may result.

Example

The following example calls the DdePostAdvise function whenever the time changes:

typedef struct { /* tm */
    int hour;
    int minute;
    int second;
} TIME;

TIME tmTime;
DWORD idInst;
HSZ hszTime;
HSZ hszNow;
TIME tmCurTime;

    .
    . /* Fill tmCurTime with the current time. */
    .


/* Check for any change in second, minute, or hour. */

if ((tmCurTime.second != tmTime.second) ||
        (tmCurTime.minute != tmTime.minute) ||
        (tmCurTime.hour   != tmTime.hour)) {

    /* Send the current time to the clients. */

    DdePostAdvise(idInst, hszTime, hszNow);

See Also

DdeInitialize