Instance-Specific String Handles (HSZs) in DDEML

ID: Q94953


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) 3.1
  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows NT, versions 3.5, 3.51
    • Microsoft Windows 95


SUMMARY

Instance-specific string handles in DDEML may be used in DdeConnect() or DdeConnectList() in order to connect to a particular instance of a server. These string handles are received by a DDEML callback as the HSZ2 parameter to the XTYP_REGISTER/XTYP_UNREGISTER transactions whenever a server application registers or unregisters the service name it supports.

This article explains how instance-specific HSZs are internally implemented in the Windows 3.1 DDEML; however, this is for purposes of illustration only because the implementation may change in future versions of DDEML, particularly in Win32. However, the behavior will be the same.


MORE INFORMATION

Currently, instance-specific string handles contain two pieces of information: the original service name string plus the handle to a hidden window created by DDEML, which is associated with that string. These two pieces of information are then merged [that is, MAKELONG (SvcNameAtom, hWnd)] into an HSZ.

It is important to underscore what the documents on DdeCreateStringHandle() say in reference to instance-specific HSZs (see the Comments section of the Windows 3.1 Software Development Kit (SDK) "Programmer's Reference, Volume 2: Functions," page 169):

An instance-specific string handle is not mappable from string handle to string to string handle again. The DdeQueryString() function creates a string from a string handle and then DdeCreateStringHandle() creates a string handle from that string, but the two handles are not the same.
This might be better explained as follows:
  1. Server registers itself:
    
          0x0000C18F = DdeCreateStringHandle (,"SERVER",);
          DdeNameService (,0x0000C18F,,); 


  2. Callbacks receive two HSZs in XTYP_REGISTER:
    
          HSZ1 = 0x0000C18F  (normal HSZ)
          HSZ2 = 0x56F8C18F  (instance-specific HSZ) 


  3. Client does a DdeQueryString() on the HSZ2 returned above, and creates a string handle with the string returned.
    
          DdeQueryString (,0x56F8C18F, myLpstr,,,);
                // where myLpstr returned = "SERVER:(56F8)" 



      0x0000C193= DdeCreateStringHandle (,myLpstr,); 
Note how instance-specific 0x56F8C18F passed in to DdeQueryString() is not the same as the HSZ returned (0x0000C193) from the DdeCreateStringHandle() on the same string; whereas regular string handles (that is, non-instance-specific HSZs) would have mapped to the same string handle.

Additional query words: 3.10 3.50 4.00

Keywords : kbNTOS350 kbNTOS351 kbWinOS95
Version :
Platform :
Issue type :


Last Reviewed: September 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.