' ########################################################################################
' Microsoft Windows
' File: ddeml.inc
' Contents: DDEML API header file
' Version 3.10
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_Ddeml_PBI)
#DEFINE PBX_Ddeml_PBI
%EQUATE `DDEML_INC = 1
#INCLUDE ONCE "Core/Windows.inc"
'/******** public types ********/
'DECLARE_HANDLE(HCONVLIST);
'DECLARE_HANDLE(HCONV);
'DECLARE_HANDLE(HSZ);
'DECLARE_HANDLE(HDDEDATA);
'#define EXPENTRY CALLBACK
'/* the following structure is for use with XTYP_WILDCONNECT processing. */
' // Size = 8 bytes
TYPE HSZPAIR DWORD
 hszSvc AS DWORD ' HSZ hszSvc
 hszTopic AS DWORD ' HSZ hszTopic
END TYPE
'/* The following structure is used by DdeConnect() and DdeConnectList() and
' by XTYP_CONNECT and XTYP_WILDCONNECT callbacks. */
' // Size = 36 bytes
TYPE CONVCONTEXT DWORD
 cb AS DWORD ' UINT cb /* set to sizeof(CONVCONTEXT) */
 wFlags AS DWORD ' UINT wFlags /* none currently defined. */
 wCountryID AS DWORD ' UINT wCountryID /* country code for topic/item strings used. */
 iCodePage AS LONG ' int iCodePage /* codepage used for topic/item strings. */
 dwLangID AS DWORD ' DWORD dwLangID /* language ID for topic/item strings. */
 dwSecurity AS DWORD ' DWORD dwSecurity /* Private security code. */
 qos AS SECURITY_QUALITY_OF_SERVICE ' SECURITY_QUALITY_OF_SERVICE qos; /* client side's quality of service */
END TYPE
'/* The following structure is used by DdeQueryConvInfo(): */
' // Size = 96 bytes
TYPE CONVINFO DWORD
 cb AS DWORD ' DWORD cb; /* sizeof(CONVINFO) */
 hUser AS DWORD ' DWORD_PTR hUser; /* user specified field */
 hConvPartner AS DWORD ' HCONV hConvPartner; /* hConv on other end or 0 if non-ddemgr partner */
 hszSvcPartner AS DWORD ' HSZ hszSvcPartner; /* app name of partner if obtainable */
 hszServiceReq AS DWORD ' HSZ hszServiceReq; /* AppName requested for connection */
 hszTopic AS DWORD ' HSZ hszTopic; /* Topic name for conversation */
 hszItem AS DWORD ' HSZ hszItem; /* transaction item name or NULL if quiescent */
 wFmt AS DWORD ' UINT wFmt; /* transaction format or NULL if quiescent */
 wType AS DWORD ' UINT wType; /* XTYP_ for current transaction */
 wStatus AS DWORD ' UINT wStatus; /* ST_ constant for current conversation */
 wConvst AS DWORD ' UINT wConvst; /* XST_ constant for current transaction */
 wLastError AS DWORD ' UINT wLastError; /* last transaction error. */
 hConvList AS DWORD ' HCONVLIST hConvList; /* parent hConvList if this conversation is in a list */
 ConvCtxt AS CONVCONTEXT ' CONVCONTEXT ConvCtxt; /* conversation context */
 hWnd AS DWORD ' HWND hwnd; /* window handle for this conversation */
 hwndPartner AS DWORD ' HWND hwndPartner; /* partner window handle for this conversation */
END TYPE
'/***** conversation states (usState) *****/
%EQUATE `XST_NULL = 0 ' quiescent states
%EQUATE `XST_INCOMPLETE = 1
%EQUATE `XST_CONNECTED = 2
%EQUATE `XST_INIT1 = 3 ' mid-initiation states
%EQUATE `XST_INIT2 = 4
%EQUATE `XST_REQSENT = 5 ' active conversation states
%EQUATE `XST_DATARCVD = 6
%EQUATE `XST_POKESENT = 7
%EQUATE `XST_POKEACKRCVD = 8
%EQUATE `XST_EXECSENT = 9
%EQUATE `XST_EXECACKRCVD = 10
%EQUATE `XST_ADVSENT = 11
%EQUATE `XST_UNADVSENT = 12
%EQUATE `XST_ADVACKRCVD = 13
%EQUATE `XST_UNADVACKRCVD = 14
%EQUATE `XST_ADVDATASENT = 15
%EQUATE `XST_ADVDATAACKRCVD = 16
'/* used in LOWORD(dwData1) of XTYP_ADVREQ callbacks... */
%EQUATE `CADV_LATEACK = &HFFFF
'/***** conversation status bits (fsStatus) *****/
%EQUATE `ST_CONNECTED = &H0001
%EQUATE `ST_ADVISE = &H0002
%EQUATE `ST_ISLOCAL = &H0004
%EQUATE `ST_BLOCKED = &H0008
%EQUATE `ST_CLIENT = &H0010
%EQUATE `ST_TERMINATED = &H0020
%EQUATE `ST_INLIST = &H0040
%EQUATE `ST_BLOCKNEXT = &H0080
%EQUATE `ST_ISSELF = &H0100
'/* DDE constants for wStatus field */
%EQUATE `DDE_FACK = &H8000
%EQUATE `DDE_FBUSY = &H4000
%EQUATE `DDE_FDEFERUPD = &H4000
%EQUATE `DDE_FACKREQ = &H8000
%EQUATE `DDE_FRELEASE = &H2000
%EQUATE `DDE_FREQUESTED = &H1000
%EQUATE `DDE_FAPPSTATUS = &H00FF
%EQUATE `DDE_FNOTPROCESSED = &H0000
%EQUATE `DDE_FACKRESERVED = NOT (%DDE_FACK OR %DDE_FBUSY OR %DDE_FAPPSTATUS)
%EQUATE `DDE_FADVRESERVED = NOT (%DDE_FACKREQ OR %DDE_FDEFERUPD)
%EQUATE `DDE_FDATRESERVED = NOT (%DDE_FACKREQ OR %DDE_FRELEASE OR %DDE_FREQUESTED)
%EQUATE `DDE_FPOKRESERVED = NOT (%DDE_FRELEASE)
'/***** message filter hook types *****/
%EQUATE `MSGF_DDEMGR = &H8001&
'/***** codepage constants ****/
%EQUATE `CP_WINANSI = 1004& ' default codepage for windows old DDE convs.
%EQUATE `CP_WINUNICODE = 1200&
'/***** transaction types *****/
%EQUATE `XTYPF_NOBLOCK = &H0002 ' CBR_BLOCK will not work
%EQUATE `XTYPF_NODATA = &H0004 ' DDE_FDEFERUPD
%EQUATE `XTYPF_ACKREQ = &H0008 ' DDE_FACKREQ
%EQUATE `XCLASS_MASK = &HFC00
%EQUATE `XCLASS_BOOL = &H1000
%EQUATE `XCLASS_DATA = &H2000
%EQUATE `XCLASS_FLAGS = &H4000
%EQUATE `XCLASS_NOTIFICATION = &H8000
%EQUATE `XTYP_ERROR = &H0000 OR %XCLASS_NOTIFICATION OR %XTYPF_NOBLOCK
%EQUATE `XTYP_ADVDATA = &H0010 OR %XCLASS_FLAGS
%EQUATE `XTYP_ADVREQ = &H0020 OR %XCLASS_DATA OR %XTYPF_NOBLOCK
%EQUATE `XTYP_ADVSTART = &H0030 OR %XCLASS_BOOL
%EQUATE `XTYP_ADVSTOP = &H0040 OR %XCLASS_NOTIFICATION
%EQUATE `XTYP_EXECUTE = &H0050 OR %XCLASS_FLAGS
%EQUATE `XTYP_CONNECT = &H0060 OR %XCLASS_BOOL OR %XTYPF_NOBLOCK
%EQUATE `XTYP_CONNECT_CONFIRM = &H0070 OR %XCLASS_NOTIFICATION OR %XTYPF_NOBLOCK
%EQUATE `XTYP_XACT_COMPLETE = &H0080 OR %XCLASS_NOTIFICATION
%EQUATE `XTYP_POKE = &H0090 OR %XCLASS_FLAGS
%EQUATE `XTYP_REGISTER = &H00A0 OR %XCLASS_NOTIFICATION OR %XTYPF_NOBLOCK
%EQUATE `XTYP_REQUEST = &H00B0 OR %XCLASS_DATA
%EQUATE `XTYP_DISCONNECT = &H00C0 OR %XCLASS_NOTIFICATION OR %XTYPF_NOBLOCK
%EQUATE `XTYP_UNREGISTER = &H00D0 OR %XCLASS_NOTIFICATION OR %XTYPF_NOBLOCK
%EQUATE `XTYP_WILDCONNECT = &H00E0 OR %XCLASS_DATA OR %XTYPF_NOBLOCK
%EQUATE `XTYP_MASK = &H00F0
%EQUATE `XTYP_SHIFT = 4 ' shift to turn XTYP_ into an index
'/***** Timeout constants *****/
%EQUATE `TIMEOUT_ASYNC = &HFFFFFFFF
'/***** Transaction ID constants *****/
%EQUATE `QID_SYNC = &HFFFFFFFF
'/****** public strings used in DDE ******/
'#ifdef UNICODE
'#define SZDDESYS_TOPIC L"System"
'#define SZDDESYS_ITEM_TOPICS L"Topics"
'#define SZDDESYS_ITEM_SYSITEMS L"SysItems"
'#define SZDDESYS_ITEM_RTNMSG L"ReturnMessage"
'#define SZDDESYS_ITEM_STATUS L"Status"
'#define SZDDESYS_ITEM_FORMATS L"Formats"
'#define SZDDESYS_ITEM_HELP L"Help"
'#define SZDDE_ITEM_ITEMLIST L"TopicItemList"
'#else
'#define SZDDESYS_TOPIC "System"
'#define SZDDESYS_ITEM_TOPICS "Topics"
'#define SZDDESYS_ITEM_SYSITEMS "SysItems"
'#define SZDDESYS_ITEM_RTNMSG "ReturnMessage"
'#define SZDDESYS_ITEM_STATUS "Status"
'#define SZDDESYS_ITEM_FORMATS "Formats"
'#define SZDDESYS_ITEM_HELP "Help"
'#define SZDDE_ITEM_ITEMLIST "TopicItemList"
'#endif
$$SZDDESYS_TOPIC = "System"$$
$$SZDDESYS_ITEM_TOPICS = "Topics"$$
$$SZDDESYS_ITEM_SYSITEMS = "SysItems"$$
$$SZDDESYS_ITEM_RTNMSG = "ReturnMessage"$$
$$SZDDESYS_ITEM_STATUS = "Status"$$
$$SZDDESYS_ITEM_FORMATS = "Formats"$$
$$SZDDESYS_ITEM_HELP = "Help"$$
$$SZDDE_ITEM_ITEMLIST = "TopicItemList"$$
$SZDDESYS_TOPIC = "System"
$SZDDESYS_ITEM_TOPICS = "Topics"
$SZDDESYS_ITEM_SYSITEMS = "SysItems"
$SZDDESYS_ITEM_RTNMSG = "ReturnMessage"
$SZDDESYS_ITEM_STATUS = "Status"
$SZDDESYS_ITEM_FORMATS = "Formats"
$SZDDESYS_ITEM_HELP = "Help"
$SZDDE_ITEM_ITEMLIST = "TopicItemList"
#IF %DEF(%UNICODE)
MACRO SZDDESYS_TOPIC = $$SZDDESYS_TOPIC
MACRO SZDDESYS_ITEM_TOPICS = $$SZDDESYS_ITEM_TOPICS
MACRO SZDDESYS_ITEM_SYSITEMS = $$SZDDESYS_ITEM_SYSITEMS
MACRO SZDDESYS_ITEM_RTNMSG = $$SZDDESYS_ITEM_RTNMSG
MACRO SZDDESYS_ITEM_STATUS = $$SZDDESYS_ITEM_STATUS
MACRO SZDDESYS_ITEM_FORMATS = $$SZDDESYS_ITEM_FORMATS
MACRO SZDDESYS_ITEM_HELP = $$SZDDESYS_ITEM_HELP
MACRO SZDDE_ITEM_ITEMLIST = $$SZDDE_ITEM_ITEMLIST
#ELSE
MACRO SZDDESYS_TOPIC = $SZDDESYS_TOPIC
MACRO SZDDESYS_ITEM_TOPICS = $SZDDESYS_ITEM_TOPICS
MACRO SZDDESYS_ITEM_SYSITEMS = $SZDDESYS_ITEM_SYSITEMS
MACRO SZDDESYS_ITEM_RTNMSG = $SZDDESYS_ITEM_RTNMSG
MACRO SZDDESYS_ITEM_STATUS = $SZDDESYS_ITEM_STATUS
MACRO SZDDESYS_ITEM_FORMATS = $SZDDESYS_ITEM_FORMATS
MACRO SZDDESYS_ITEM_HELP = $SZDDESYS_ITEM_HELP
MACRO SZDDE_ITEM_ITEMLIST = $SZDDE_ITEM_ITEMLIST
#ENDIF
'/****** API entry points ******/
'typedef HDDEDATA CALLBACK FNCALLBACK(UINT wType, UINT wFmt, HCONV hConv,
' HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG_PTR dwData1, ULONG_PTR dwData2);
'typedef HDDEDATA (CALLBACK *PFNCALLBACK)(UINT wType, UINT wFmt, HCONV hConv,
' HSZ hsz1, HSZ hsz2, HDDEDATA hData, ULONG_PTR dwData1, ULONG_PTR dwData2);
'#define CBR_BLOCK ((HDDEDATA)-1)
%EQUATE `CBR_BLOCK = &HFFFFFFFF
'/* DLL registration functions */
DECLARE FUNCTION DdeInitializeA LIB "user32.dll" ALIAS "DdeInitializeA" ( BYREF pidInst AS QUAD , BYVAL pfnCallback AS QUAD , BYVAL afCmd AS QUAD , BYVAL ulRes AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION DdeInitializeW LIB "user32.dll" ALIAS "DdeInitializeW" ( BYREF pidInst AS QUAD , BYVAL pfnCallback AS QUAD , BYVAL afCmd AS QUAD , BYVAL ulRes AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO DdeInitialize = DdeInitializeW
#ELSE
 MACRO DdeInitialize = DdeInitializeA
#ENDIF
'/*
' * Callback filter flags for use with standard apps.
' */
%EQUATE `CBF_FAIL_SELFCONNECTIONS = &H00001000
%EQUATE `CBF_FAIL_CONNECTIONS = &H00002000
%EQUATE `CBF_FAIL_ADVISES = &H00004000
%EQUATE `CBF_FAIL_EXECUTES = &H00008000
%EQUATE `CBF_FAIL_POKES = &H00010000
%EQUATE `CBF_FAIL_REQUESTS = &H00020000
%EQUATE `CBF_FAIL_ALLSVRXACTIONS = &H0003F000
%EQUATE `CBF_SKIP_CONNECT_CONFIRMS = &H00040000
%EQUATE `CBF_SKIP_REGISTRATIONS = &H00080000
%EQUATE `CBF_SKIP_UNREGISTRATIONS = &H00100000
%EQUATE `CBF_SKIP_DISCONNECTS = &H00200000
%EQUATE `CBF_SKIP_ALLNOTIFICATIONS = &H003C0000
'/*
' * Application command flags
' */
%EQUATE `APPCMD_CLIENTONLY = &H00000010
%EQUATE `APPCMD_FILTERINITS = &H00000020
%EQUATE `APPCMD_MASK = &H00000FF0
'/*
' * Application classification flags
' */
%EQUATE `APPCLASS_STANDARD = &H00000000
%EQUATE `APPCLASS_MASK = &H0000000F
DECLARE FUNCTION DdeUninitialize LIB "user32.dll" ALIAS "DdeUninitialize" ( BYVAL idInst AS QUAD ) AS LONG
'/*
' * conversation enumeration functions
' */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION DdeConnectList LIB "User32.dll" ALIAS "DdeConnectList" ( BYVAL idInst AS QUAD, BYVAL hszService AS QUAD, ' HSZ
 BYVAL hszTopic AS DWORD, ' HSZ
 BYVAL hConvList AS DWORD, ' HCONVLIST
 OPTIONAL BYVAL pCC AS CONVCONTEXT PTR ) AS DWORD ' HCONVLIST
#ELSE
DECLARE FUNCTION DdeConnectList LIB "user32.dll" ALIAS "DdeConnectList" ( BYVAL idInst AS QUAD , BYVAL hszService AS QUAD , BYVAL hszTopic AS QUAD , BYVAL hConvList AS QUAD , OPTIONAL BYREF pCC AS CONVCONTEXT ) AS QUAD ' HCONVLIST
#ENDIF
DECLARE FUNCTION DdeQueryNextServer LIB "user32.dll" ALIAS "DdeQueryNextServer" ( BYVAL hConvList AS QUAD , BYVAL hConvPrev AS QUAD ) AS QUAD ' HCONV
DECLARE FUNCTION DdeDisconnectList LIB "user32.dll" ALIAS "DdeDisconnectList" ( BYVAL hConvList AS QUAD ) AS LONG
'/*
' * conversation control functions
' */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION DdeConnect LIB "User32.dll" ALIAS "DdeConnect" ( BYVAL idInst AS QUAD, BYVAL hszService AS QUAD, ' HSZ
 BYVAL hszTopic AS DWORD, ' HSZ
 OPTIONAL BYVAL pCC AS CONVCONTEXT PTR ) AS DWORD ' HCONV
#ELSE
DECLARE FUNCTION DdeConnect LIB "user32.dll" ALIAS "DdeConnect" ( BYVAL idInst AS QUAD , BYVAL hszService AS QUAD , BYVAL hszTopic AS QUAD , OPTIONAL BYREF pCC AS CONVCONTEXT ) AS QUAD ' HCONV
#ENDIF
DECLARE FUNCTION DdeDisconnect LIB "user32.dll" ALIAS "DdeDisconnect" ( BYVAL hConv AS QUAD ) AS LONG
DECLARE FUNCTION DdeReconnect LIB "user32.dll" ALIAS "DdeReconnect" ( BYVAL hConv AS QUAD
 ) AS DWORD ' HCONV
DECLARE FUNCTION DdeQueryConvInfo LIB "user32.dll" ALIAS "DdeQueryConvInfo" ( BYVAL hConv AS QUAD , BYVAL idTransaction AS QUAD , BYREF pConvInfo AS CONVINFO ) AS QUAD ' UINT
DECLARE FUNCTION DdeSetUserHandle LIB "user32.dll" ALIAS "DdeSetUserHandle" ( BYVAL hConv AS QUAD , BYVAL id AS QUAD , BYVAL hUser AS QUAD ) AS LONG
DECLARE FUNCTION DdeAbandonTransaction LIB "user32.dll" ALIAS "DdeAbandonTransaction" ( BYVAL idInst AS QUAD
 , BYVAL hConv AS DWORD
 , BYVAL idTransaction AS DWORD
 ) AS LONG
'/*
' * app server interface functions
' */
DECLARE FUNCTION DdePostAdvise LIB "user32.dll" ALIAS "DdePostAdvise" ( BYVAL idInst AS QUAD , BYVAL hszTopic AS QUAD , BYVAL hszItem AS QUAD ) AS LONG
DECLARE FUNCTION DdeEnableCallback LIB "user32.dll" ALIAS "DdeEnableCallback" ( BYVAL idInst AS QUAD
 , BYVAL hConv AS DWORD
 , BYVAL wCmd AS DWORD
 ) AS LONG
DECLARE FUNCTION DdeImpersonateClient LIB "user32.dll" ALIAS "DdeImpersonateClient" ( BYVAL hConv AS DWORD
 ) AS LONG
%EQUATE `EC_ENABLEALL = 0
%EQUATE `EC_ENABLEONE = %ST_BLOCKNEXT
%EQUATE `EC_DISABLE = %ST_BLOCKED
%EQUATE `EC_QUERYWAITING = 2
DECLARE FUNCTION DdeNameService LIB "user32.dll" ALIAS "DdeNameService" ( BYVAL idInst AS QUAD , BYVAL hsz1 AS QUAD , BYVAL hsz2 AS QUAD , BYVAL afCmd AS LONG ) AS QUAD ' HDDEDATA
%EQUATE `DNS_REGISTER = &H0001
%EQUATE `DNS_UNREGISTER = &H0002
%EQUATE `DNS_FILTERON = &H0004
%EQUATE `DNS_FILTEROFF = &H0008
'/*
' * app client interface functions
' */
DECLARE FUNCTION DdeClientTransaction LIB "user32.dll" ALIAS "DdeClientTransaction" ( BYVAL pData AS BYTE PTR , BYVAL cbData AS QUAD , BYVAL hConv AS QUAD , BYVAL hszItem AS QUAD , BYVAL wFmt AS QUAD , BYVAL wType AS QUAD , BYVAL dwTimeout AS QUAD , BYREF pdwResult AS QUAD ) AS QUAD ' HDDEDATA
'/*
' *data transfer functions
' */
DECLARE FUNCTION DdeCreateDataHandle LIB "user32.dll" ALIAS "DdeCreateDataHandle" ( BYVAL idInst AS QUAD , BYVAL pSrc AS BYTE PTR , BYVAL cb AS QUAD , BYVAL cbOff AS QUAD , BYVAL hszItem AS QUAD , BYVAL wFmt AS QUAD , BYVAL afCmd AS QUAD ) AS QUAD ' HDDEDATA
DECLARE FUNCTION DdeAddData LIB "user32.dll" ALIAS "DdeAddData" ( BYVAL hData AS QUAD , BYVAL pSrc AS BYTE PTR , BYVAL cb AS QUAD , BYVAL cbOff AS QUAD ) AS QUAD ' HDDEDATA
DECLARE FUNCTION DdeGetData LIB "user32.dll" ALIAS "DdeGetData" ( BYVAL hData AS QUAD , BYVAL pDst AS BYTE PTR , BYVAL cbMax AS QUAD , BYVAL cbOff AS QUAD ) AS QUAD
DECLARE FUNCTION DdeAccessData LIB "user32.dll" ALIAS "DdeAccessData" ( BYVAL hData AS QUAD
 , BYREF pcbDataSize AS DWORD
 ) AS DWORD
DECLARE FUNCTION DdeUnaccessData LIB "user32.dll" ALIAS "DdeUnaccessData" ( BYVAL hData AS DWORD
 ) AS LONG
'#IF %DEF(%USEPBDECL)
'DECLARE FUNCTION DdeFreeDataHandle LIB "User32.dll" ' ALIAS "DdeFreeDataHandle" ( ' hData AS DWORD ' HDDEDATA ' // This is wrong. It should be BYVAL
' ) AS LONG
'#ELSE
DECLARE FUNCTION DdeFreeDataHandle LIB "user32.dll" ALIAS "DdeFreeDataHandle" ( BYVAL hData AS QUAD ) AS LONG
'#ENDIF
%EQUATE `HDATA_APPOWNED = &H0001
DECLARE FUNCTION DdeGetLastError LIB "user32.dll" ALIAS "DdeGetLastError" ( BYVAL idInst AS QUAD ) AS QUAD ' UINT
%EQUATE `DMLERR_NO_ERROR = 0 ' must be 0
%EQUATE `DMLERR_FIRST = &H4000
%EQUATE `DMLERR_ADVACKTIMEOUT = &H4000
%EQUATE `DMLERR_BUSY = &H4001
%EQUATE `DMLERR_DATAACKTIMEOUT = &H4002
%EQUATE `DMLERR_DLL_NOT_INITIALIZED = &H4003
%EQUATE `DMLERR_DLL_USAGE = &H4004
%EQUATE `DMLERR_EXECACKTIMEOUT = &H4005
%EQUATE `DMLERR_INVALIDPARAMETER = &H4006
%EQUATE `DMLERR_LOW_MEMORY = &H4007
%EQUATE `DMLERR_MEMORY_ERROR = &H4008
%EQUATE `DMLERR_NOTPROCESSED = &H4009
%EQUATE `DMLERR_NO_CONV_ESTABLISHED = &H400A
%EQUATE `DMLERR_POKEACKTIMEOUT = &H400B
%EQUATE `DMLERR_POSTMSG_FAILED = &H400C
%EQUATE `DMLERR_REENTRANCY = &H400D
%EQUATE `DMLERR_SERVER_DIED = &H400E
%EQUATE `DMLERR_SYS_ERROR = &H400F
%EQUATE `DMLERR_UNADVACKTIMEOUT = &H4010
%EQUATE `DMLERR_UNFOUND_QUEUE_ID = &H4011
%EQUATE `DMLERR_LAST = &H4011
DECLARE FUNCTION DdeCreateStringHandleA LIB "user32.dll" ALIAS "DdeCreateStringHandleA" ( BYVAL idInst AS QUAD , BYREF psz AS ASCIIZ , BYVAL iCodePage AS QUAD ) AS QUAD ' HSZ
DECLARE FUNCTION DdeCreateStringHandleW LIB "user32.dll" ALIAS "DdeCreateStringHandleW" ( BYVAL idInst AS QUAD , BYREF psz AS WSTRINGZ , BYVAL iCodePage AS QUAD ) AS QUAD ' HSZ
#IF %DEF(%UNICODE)
 MACRO DdeCreateStringHandle = DdeCreateStringHandleW
#ELSE
 MACRO DdeCreateStringHandle = DdeCreateStringHandleA
#ENDIF
DECLARE FUNCTION DdeQueryStringA LIB "user32.dll" ALIAS "DdeQueryStringA" ( BYVAL idInst AS QUAD , BYVAL hsz AS QUAD , BYREF psz AS ASCIIZ , BYVAL cchMax AS QUAD , BYVAL iCodePage AS LONG ) AS QUAD
DECLARE FUNCTION DdeQueryStringW LIB "user32.dll" ALIAS "DdeQueryStringW" ( BYVAL idInst AS QUAD
 , BYVAL hsz AS DWORD
 , BYREF psz AS WSTRINGZ
 , BYVAL cchMax AS DWORD
 , BYVAL iCodePage AS LONG
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO DdeQueryString = DdeQueryStringW
#ELSE
 MACRO DdeQueryString = DdeQueryStringA
#ENDIF
DECLARE FUNCTION DdeFreeStringHandle LIB "user32.dll" ALIAS "DdeFreeStringHandle" ( BYVAL idInst AS QUAD , BYVAL hsz AS QUAD ) AS LONG
DECLARE FUNCTION DdeKeepStringHandle LIB "user32.dll" ALIAS "DdeKeepStringHandle" ( BYVAL idInst AS QUAD
 , BYVAL hsz AS DWORD
 ) AS LONG
DECLARE FUNCTION DdeCmpStringHandles LIB "user32.dll" ALIAS "DdeCmpStringHandles" ( BYVAL hsz1 AS DWORD
 , BYVAL hsz2 AS DWORD
 ) AS LONG ' int
'#ifndef NODDEMLSPY
'/*
' * DDEML public debugging header file info
' */
' // Size = 44 bytes
TYPE DDEML_MSG_HOOK_DATA
 uiLo AS DWORD ' UINT_PTR uiLo; // unpacked lo and hi parts of lParam
 uiHi AS DWORD ' UINT_PTR uiHi;
 cbData AS DWORD ' DWORD cbData; // amount of data in message, if any. May be > than 32 bytes.
 Data(7) AS DWORD ' DWORD Data[8]; // data peeking by DDESPY is limited to 32 bytes.
END TYPE
' // Size = 72 bytes
TYPE MONMSGSTRUCT DWORD
 cb AS DWORD ' UINT cb
 hWndTo AS DWORD ' HWND hwndTo
 dwTime AS DWORD ' DWORD dwTime
 htask AS DWORD ' HANDLE hTask
 wMsg AS DWORD ' UINT wMsg
 wParam AS DWORD ' WPARAM wParam
 lParam AS LONG ' LPARAM lParam
 dmhd AS DDEML_MSG_HOOK_DATA ' DDEML_MSG_HOOK_DATA dmhd; // new for NT
END TYPE
' // Size = 120 bytes
TYPE MONCBSTRUCT DWORD
 cb AS DWORD ' UINT cb
 dwTime AS DWORD ' DWORD dwTime
 htask AS DWORD ' HANDLE hTask
 dwRet AS DWORD ' DWORD dwRet
 wType AS DWORD ' UINT wType
 wFmt AS DWORD ' UINT wFmt
 hConv AS DWORD ' HCONV hConv
 hsz1 AS DWORD ' HSZ hsz1
 hsz2 AS DWORD ' HSZ hsz2
 hData AS DWORD ' HDDEDATA hData
 dwData1 AS DWORD ' ULONG_PTR dwData1
 dwData2 AS DWORD ' ULONG_PTR dwData2
 cc AS CONVCONTEXT ' CONVCONTEXT cc; // new for NT for XTYP_CONNECT callbacks
 cbData AS DWORD ' DWORD cbData; // new for NT for data peeking
 Data(7) AS DWORD ' DWORD Data[8]; // new for NT for data peeking
END TYPE
' // Size = 24 bytes
TYPE MONHSZSTRUCTA DWORD
 cb AS DWORD ' UINT cb
 fsAction AS LONG ' BOOL fsAction; /* MH_ value */
 dwTime AS DWORD ' DWORD dwTime
 hsz AS DWORD ' HSZ hsz
 htask AS DWORD ' HANDLE hTask
 str AS ASCIIZ * 1 ' CHAR str[1]
END TYPE
' // Size = 24 bytes
TYPE MONHSZSTRUCTW DWORD
 cb AS DWORD ' UINT cb
 fsAction AS LONG ' BOOL fsAction; /* MH_ value */
 dwTime AS DWORD ' DWORD dwTime
 hsz AS DWORD ' HSZ hsz
 htask AS DWORD ' HANDLE hTask
 str AS WSTRINGZ * 1 ' WCHAR str[1]
END TYPE
#IF %DEF(%UNICODE)
 MACRO MONHSZSTRUCT = MONHSZSTRUCTW
#ELSE
 MACRO MONHSZSTRUCT = MONHSZSTRUCTA
#ENDIF
%EQUATE `MH_CREATE = 1
%EQUATE `MH_KEEP = 2
%EQUATE `MH_DELETE = 3
%EQUATE `MH_CLEANUP = 4
' // Size = 16 bytes
TYPE MONERRSTRUCT DWORD
 cb AS DWORD ' UINT cb
 wLastError AS DWORD ' UINT wLastError
 dwTime AS DWORD ' DWORD dwTime
 htask AS DWORD ' HANDLE hTask
END TYPE
' // Size = 48 bytes
TYPE MONLINKSTRUCT DWORD
 cb AS DWORD ' UINT cb
 dwTime AS DWORD ' DWORD dwTime
 htask AS DWORD ' HANDLE hTask
 fEstablished AS LONG ' BOOL fEstablished
 fNoData AS LONG ' BOOL fNoData
 hszSvc AS LONG ' HSZ hszSvc
 hszTopic AS DWORD ' HSZ hszTopic
 hszItem AS DWORD ' HSZ hszItem
 wFmt AS DWORD ' UINT wFmt
 fServer AS LONG ' BOOL fServer
 hConvServer AS LONG ' HCONV hConvServer
 hConvClient AS LONG ' HCONV hConvClient
END TYPE
' // Size = 32 bytes
TYPE MONCONVSTRUCT DWORD
 cb AS DWORD ' UINT cb
 fConnect AS LONG ' BOOL fConnect
 dwTime AS DWORD ' DWORD dwTime
 htask AS DWORD ' HANDLE hTask
 hszSvc AS LONG ' HSZ hszSvc
 hszTopic AS DWORD ' HSZ hszTopic
 hConvClient AS DWORD ' HCONV hConvClient // Globally unique value != apps local hConv
 hConvServer AS DWORD ' HCONV hConvServer // Globally unique value != apps local hConv
END TYPE
%EQUATE `MAX_MONITORS = 4
%EQUATE `APPCLASS_MONITOR = &H00000001
%EQUATE `XTYP_MONITOR = &H00F0 OR %XCLASS_NOTIFICATION OR %XTYPF_NOBLOCK
'/*
' * Callback filter flags for use with MONITOR apps - 0 implies no monitor
' * callbacks.
' */
%EQUATE `MF_HSZ_INFO = &H01000000
%EQUATE `MF_SENDMSGS = &H02000000
%EQUATE `MF_POSTMSGS = &H04000000
%EQUATE `MF_CALLBACKS = &H08000000
%EQUATE `MF_ERRORS = &H10000000
%EQUATE `MF_LINKS = &H20000000
%EQUATE `MF_CONV = &H40000000
%EQUATE `MF_MASK = &HFF000000
'#endif /* NODDEMLSPY */
#ENDIF
