DdeCmpStringHandles

3.1

  #include <ddeml.h>    

  int DdeCmpStringHandles(hsz1, hsz2)    
  HSZ hsz1; /* handle of first string */
  HSZ hsz2; /* handle of second string */

The DdeCmpStringHandles function compares the values of two string handles. The value of a string handle is not related to the case of the associated string.

Parameters

hsz1

Specifies the first string handle.

hsz2

Specifies the second string handle.

Return Value

The return value can be one of the following:

Value Meaning

–1 The value of hsz1 is either 0 or less than the value of hsz2.
0 The values of hsz1 and hsz2 are equal (both can be 0).
1 The value of hsz2 is either 0 or less than the value of hsz1.

Comments

An application that needs to do a case-sensitive comparison of two string handles should compare the string handles directly. An application should use DdeCompStringHandles for all other comparisons to preserve the case-sensitive nature of dynamic data exchange (DDE).

The DdeCompStringHandles function cannot be used to sort string handles alphabetically.

Example

This example compares two service-name string handles and, if the handles are the same, requests a conversation with the server, then issues an XTYP_ADVSTART transaction:

HSZ hszClock;   /* service name */
HSZ hszTime;    /* topic name   */
HSZ hsz1;       /* unknown server          */
HCONV hConv;    /* conversation handle     */
DWORD dwResult; /* result flags            */
DWORD idInst;   /* instance identifier     */

/*
 * Compare unknown service name handle with the string handle
 * for the clock application.
 */

if (!DdeCmpStringHandles(hsz1, hszClock)) {

    /*
     * If this is the clock application, start a conversation
     * with it and request an advise loop.
     */

    hConv = DdeConnect(idInst, hszClock, hszTime, NULL);
    if (hConv != (HCONV) NULL)
        DdeClientTransaction(NULL, 0, hConv, hszNow,
            CF_TEXT, XTYP_ADVSTART, 1000, &dwResult);

}

See Also

DdeAccessData, DdeCreateStringHandle, DdeFreeStringHandle