home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
DDEML.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-02-28
|
17KB
|
511 lines
{*******************************************************}
{ }
{ Delphi Runtime Library }
{ Windows 32bit API Interface Unit }
{ }
{ Copyright (c) 1992-1997 Borland International }
{ }
{*******************************************************}
unit Ddeml; // $Revision: 1.2 $
interface
uses Windows;
type
HConvList = Longint;
HConv = Longint;
HSz = Longint;
HDDEData = Longint;
type
{ the following structure is for use with xtyp_WildConnect processing. }
PHSZPair = ^THSZPair;
tagHSZPAIR = record
hszSvc: HSZ;
hszTopic: HSZ;
end;
{$nonamespace tagHSZPAIR}
THSZPair = tagHSZPAIR;
{ The following structure is used by DdeConnect() and DdeConnectList()
and by xtyp_Connect and xtyp_WildConnect callbacks. }
PConvContext = ^TConvContext;
tagCONVCONTEXT = record
cb: UINT; { set to sizeof(ConvCOnTEXT) }
wFlags: UINT; { none currently defined. }
wCountryID: UINT; { country code for topic/item strings used. }
iCodePage: Integer; { codepage used for topic/item strings. }
dwLangID: DWORD; { language ID for topic/item strings. }
dwSecurity: DWORD; { Private security code. }
qos: TSecurityQualityOfService; { used to support client impersonation }
end;
{$nonamespace tagCONVCONTEXT}
TConvContext = tagCONVCONTEXT;
{ The following structure is used by DdeQueryConvInfo(): }
PConvInfo = ^TConvInfo;
tagCONVINFO = record
cb: DWORD; { sizeof(CONVINFO) }
hUser: DWORD; { user specified field }
hConvPartner: HConv; { hConv on other end or 0 if non-ddemgr partner }
hszSvcPartner: HSz; { app name of partner if obtainable }
hszServiceReq: HSz; { AppName requested for connection }
hszTopic: HSz; { Topic name for conversation }
hszItem: HSz; { transaction item name or NULL if quiescent }
wFmt: UINT; { transaction format or NULL if quiescent }
wType: UINT; { XTYP_ for current transaction }
wStatus: UINT; { ST_ constant for current conversation }
wConvst: UINT; { XST_ constant for current transaction }
wLastError: UINT; { last transaction error. }
hConvList: HConvList; { parent hConvList if this conversation is in a list }
ConvCtxt: TConvContext; { conversation context }
hwnd: HWND; { window handle for this conversation }
hwndPartner: HWND; { partner window handle for this conversation }
end;
{$nonamespace tagCONVINFO}
TConvInfo = tagCONVINFO;
const
{ conversation states (usState) }
XST_NULL = 0; { quiescent states }
XST_INCOMPLETE = 1;
XST_CONNECTED = 2;
XST_INIT1 = 3; { mid-initiation states }
XST_INIT2 = 4;
XST_REQSENT = 5; { active conversation states }
XST_DATARCVD = 6;
XST_POKESENT = 7;
XST_POKEACKRCVD = 8;
XST_EXECSENT = 9;
XST_EXECACKRCVD = 10;
XST_ADVSENT = 11;
XST_UNADVSENT = 12;
XST_ADVACKRCVD = 13;
XST_UNADVACKRCVD = 14;
XST_ADVDATASENT = 15;
XST_ADVDATAACKRCVD = 16;
{ used in LOWORD(dwData1) of XTYP_ADVREQ callbacks... }
CADV_LATEACK = $FFFF;
{ conversation status bits (fsStatus) }
ST_CONNECTED = $0001;
ST_ADVISE = $0002;
ST_ISLOCAL = $0004;
ST_BLOCKED = $0008;
ST_CLIENT = $0010;
ST_TERMINATED = $0020;
ST_INLIST = $0040;
ST_BLOCKNEXT = $0080;
ST_ISSELF = $0100;
{ DDE constants for wStatus field }
DDE_FACK = $8000;
DDE_FBUSY = $4000;
DDE_FDEFERUPD = $4000;
DDE_FACKREQ = $8000;
DDE_FRELEASE = $2000;
DDE_FREQUESTED = $1000;
DDE_FAPPSTATUS = $00ff;
DDE_FNOTPROCESSED = $0000;
DDE_FACKRESERVED = $3ff0;
DDE_FADVRESERVED = $3fff;
DDE_FDATRESERVED = $4fff;
DDE_FPOKRESERVED = $dfff;
{ message filter hook types }
MSGF_DDEMGR = $8001;
{ default codepage for windows & old DDE convs. }
CP_WINANSI = 1004;
CP_WINUNICOCDE = 1200;
{ transaction types }
XTYPF_NOBLOCK = $0002; { CBR_BLOCK will not work }
XTYPF_NODATA = $0004; { DDE_FDEFERUPD }
XTYPF_ACKREQ = $0008; { DDE_FACKREQ }
XCLASS_MASK = $FC00;
XCLASS_BOOL = $1000;
XCLASS_DATA = $2000;
XCLASS_FLAGS = $4000;
XCLASS_NOTIFICATION = $8000;
XTYP_ERROR = $0000 or XCLASS_NOTIFICATION or XTYPF_NOBLOCK;
XTYP_ADVDATA = $0010 or XCLASS_FLAGS;
XTYP_ADVREQ = $0020 or XCLASS_DATA or XTYPF_NOBLOCK;
XTYP_ADVSTART = $0030 or XCLASS_BOOL;
XTYP_ADVSTOP = $0040 or XCLASS_NOTIFICATION;
XTYP_EXECUTE = $0050 or XCLASS_FLAGS;
XTYP_CONNECT = $0060 or XCLASS_BOOL or XTYPF_NOBLOCK;
XTYP_CONNECT_CONFIRM = $0070 or XCLASS_NOTIFICATION or XTYPF_NOBLOCK;
XTYP_XACT_COMPLETE = $0080 or XCLASS_NOTIFICATION;
XTYP_POKE = $0090 or XCLASS_FLAGS;
XTYP_REGISTER = $00A0 or XCLASS_NOTIFICATION or XTYPF_NOBLOCK;
XTYP_REQUEST = $00B0 or XCLASS_DATA;
XTYP_DISCONNECT = $00C0 or XCLASS_NOTIFICATION or XTYPF_NOBLOCK;
XTYP_UNREGISTER = $00D0 or XCLASS_NOTIFICATION or XTYPF_NOBLOCK;
XTYP_WILDCONNECT = $00E0 or XCLASS_DATA or XTYPF_NOBLOCK;
XTYP_MASK = $00F0;
XTYP_SHIFT = 4; { shift to turn xtyp_ into an index }
{ Timeout constants }
TIMEOUT_ASYNC = -1;
{ Transaction ID constatnts }
QID_SYNC = -1;
{ public strings used in DDE }
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';
type
{ API entry points }
TFNCallback = function (CallType, Fmt: UINT; Conv: HConv; hsz1, hsz2: HSZ;
Data: HDDEData; Data1, Data2: DWORD): HDDEData stdcall;
const
CBR_BLOCK = $FFFFFFFF;
{ DLL registration functions }
function DdeInitializeA(var Inst: Longint; Callback: TFNCallback;
Cmd, Res: Longint): Longint; stdcall;
function DdeInitializeW(var Inst: Longint; Callback: TFNCallback;
Cmd, Res: Longint): Longint; stdcall;
function DdeInitialize(var Inst: Longint; Callback: TFNCallback;
Cmd, Res: Longint): Longint; stdcall;
const
{ Callback filter flags for use with standard apps. }
CBF_FAIL_SELFCONNECTIONS = $00001000;
CBF_FAIL_CONNECTIONS = $00002000;
CBF_FAIL_ADVISES = $00004000;
CBF_FAIL_EXECUTES = $00008000;
CBF_FAIL_POKES = $00010000;
CBF_FAIL_REQUESTS = $00020000;
CBF_FAIL_ALLSVRXACTIONS = $0003f000;
CBF_SKIP_CONNECT_CONFIRMS = $00040000;
CBF_SKIP_REGISTRATIONS = $00080000;
CBF_SKIP_UNREGISTRATIONS = $00100000;
CBF_SKIP_DISCONNECTS = $00200000;
CBF_SKIP_ALLNOTIFICATIONS = $003c0000;
{ Application command flags }
APPCMD_CLIENTONLY = $00000010;
APPCMD_FILTERINITS = $00000020;
APPCMD_MASK = $00000FF0;
{ Application classification flags }
APPCLASS_STANDARD = $00000000;
APPCLASS_MASK = $0000000F;
function DdeUninitialize(Inst: DWORD): BOOL; stdcall;
{ conversation enumeration functions }
function DdeConnectList(Inst: DWORD; Service, Topic: HSZ;
ConvList: HConvList; CC: PConvContext): HConvList; stdcall;
function DdeQueryNextServer(ConvList: HConvList; ConvPrev: HConv): HConv; stdcall;
function DdeDisconnectList(ConvList: HConvList): BOOL; stdcall;
{ conversation control functions }
function DdeConnect(Inst: DWORD; Service, Topic: HSZ;
CC: PConvContext): HConv; stdcall;
function DdeDisconnect(Conv: HConv): BOOL; stdcall;
function DdeReconnect(Conv: HConv): HConv; stdcall;
function DdeQueryConvInfo(Conv: HConv; Transaction: DWORD;
ConvInfo: PConvInfo): UINT; stdcall;
function DdeSetUserHandle(Conv: HConv; ID, User: DWORD): BOOL; stdcall;
function DdeAbandonTransaction(Inst: DWORD; Conv: HConv;
Transaction: DWORD): BOOL; stdcall;
{ app server interface functions }
function DdePostAdvise(Inst: DWORD; Topic, Item: HSZ): BOOL; stdcall;
function DdeEnableCallback(Inst: DWORD; Conv: HConv; Cmd: UINT): BOOL; stdcall;
const
EC_ENABLEALL = 0;
EC_ENABLEONE = ST_BLOCKNEXT;
EC_DISABLE = ST_BLOCKED;
EC_QUERYWAITING = 2;
function DdeNameService(Inst: DWORD; hsz1, hsz2: HSZ; Cmd: UINT): HDDEData; stdcall;
const
DNS_REGISTER = $0001;
DNS_UNREGISTER = $0002;
DNS_FILTERON = $0004;
DNS_FILTEROFF = $0008;
{ app client interface functions }
function DdeClientTransaction(Data: Pointer; DataLen: DWORD;
Conv: HConv; Item: HSZ; Fmt, DataType: UINT; Timeout: DWORD;
Result: PDWORD): HDDEData; stdcall;
{ data transfer functions }
function DdeCreateDataHandle(Inst: DWORD; Src: Pointer;
cb, Off: DWORD; Item: HSZ; Fmt, Cmd: UINT): HDDEData; stdcall;
function DdeAddData(Data: HDDEData; Src: Pointer;
cb, Off: DWORD): HDDEData; stdcall;
function DdeGetData(Data: HDDEData; Dst: Pointer;
Max, Off: DWORD): DWORD; stdcall;
function DdeAccessData(Data: HDDEData; DataSize: PDWORD): Pointer; stdcall;
function DdeUnaccessData(Data: HDDEData): BOOL; stdcall;
function DdeFreeDataHandle(Data: HDDEData): BOOL; stdcall;
const
HDATA_APPOWNED = $0001;
function DdeGetLastError(Inst: DWORD): UINT; stdcall;
const
{ error codes }
DMLERR_NO_ERROR = 0; { must be 0 }
DMLERR_FIRST = $4000;
DMLERR_ADVACKTIMEOUT = $4000;
DMLERR_BUSY = $4001;
DMLERR_DATAACKTIMEOUT = $4002;
DMLERR_DLL_NOT_INITIALIZED = $4003;
DMLERR_DLL_USAGE = $4004;
DMLERR_EXECACKTIMEOUT = $4005;
DMLERR_INVALIDPARAMETER = $4006;
DMLERR_LOW_MEMORY = $4007;
DMLERR_MEMORY_ERROR = $4008;
DMLERR_NOTPROCESSED = $4009;
DMLERR_NO_CONV_ESTABLISHED = $400a;
DMLERR_POKEACKTIMEOUT = $400b;
DMLERR_POSTMSG_FAILED = $400c;
DMLERR_REENTRANCY = $400D;
DMLERR_SERVER_DIED = $400E;
DMLERR_SYS_ERROR = $400F;
DMLERR_UNADVACKTIMEOUT = $4010;
DMLERR_UNFOUND_QUEUE_ID = $4011;
DMLERR_LAST = $4011;
function DdeCreateStringHandleA(Inst: DWORD; psz: PAnsiChar;
CodePage: Integer): HSZ; stdcall;
function DdeCreateStringHandleW(Inst: DWORD; psz: PWideChar;
CodePage: Integer): HSZ; stdcall;
function DdeCreateStringHandle(Inst: DWORD; psz: PChar;
CodePage: Integer): HSZ; stdcall;
function DdeQueryStringA(Inst: DWORD; HSZ: HSZ; psz: PAnsiChar;
Max: DWORD; CodePage: Integer): DWORD; stdcall;
function DdeQueryStringW(Inst: DWORD; HSZ: HSZ; psz: PWideChar;
Max: DWORD; CodePage: Integer): DWORD; stdcall;
function DdeQueryString(Inst: DWORD; HSZ: HSZ; psz: PChar;
Max: DWORD; CodePage: Integer): DWORD; stdcall;
function DdeFreeStringHandle(Inst: DWORD; HSZ: HSZ): BOOL; stdcall;
function DdeKeepStringHandle(Inst: DWORD; HSZ: HSZ): BOOL; stdcall;
function DdeCmpStringHandles(hsz1, hsz2: HSZ): Integer; stdcall;
type
{ DDEML public debugging header file info }
tagDDEML_MSG_HOOK_DATA = packed record { new for NT }
uiLo: UINT; { unpacked lo and hi parts of lParam }
uiHi: UINT;
cbData: DWORD; { amount of data in message, if any. May be > than 32 bytes. }
Data: array [0..7] of DWORD; { data peeking by DDESPY is limited to 32 bytes. }
end;
{$nonamespace tagDDEML_MSG_HOOK_DATA}
TDdemlMsgHookData = tagDDEML_MSG_HOOK_DATA;
tagMONMSGSTRUCT = packed record
cb: UINT;
hWndTo: HWND;
dwTime: DWORD;
hTask: THandle;
wMsg: UINT;
wParam: WPARAM;
lParam: LPARAM;
dmhd: TDdemlMsgHookData;
end;
{$nonamespace tagMONMSGSTRUCT}
TMonMsgStruct = tagMONMSGSTRUCT;
tagMONCBSTRUCT = packed record
cb: UINT;
dwTime: DWORD;
hTask: THandle;
dwRet: DWORD;
wType: UINT;
wFmt: UINT;
hConv: HConv;
hsz1: HSZ;
hsz2: HSZ;
hData: HDDEData;
dwData1: DWORD;
dwData2: DWORD;
cc: TConvContext; { new for NT for XTYP_CONNECT callbacks }
cbData: DWORD; { new for NT for data peeking }
Data: array [0..7] of DWORD; { new for NT for data peeking }
end;
{$nonamespace tagMONCBSTRUCT}
TMonCBStruct = tagMONCBSTRUCT;
tagMONHSZSTRUCTA = record
cb: UINT;
fsAction: BOOL; { mh_ value }
dwTime: DWORD;
HSZ: HSZ;
hTask: THandle;
Str: array[0..0] of AnsiChar;
end;
{$nonamespace tagMONHSZSTRUCTA}
TMonHSZStructA = tagMONHSZSTRUCTA;
tagMONHSZSTRUCTW = record
cb: UINT;
fsAction: BOOL; { mh_ value }
dwTime: DWORD;
HSZ: HSZ;
hTask: THandle;
Str: array[0..0] of WideChar;
end;
{$nonamespace tagMONHSZSTRUCTW}
TMonHSZStructW = tagMONHSZSTRUCTW;
TMonHSZStruct = TMonHSZStructA;
const
MH_CREATE = 1;
MH_KEEP = 2;
MH_DELETE = 3;
MH_CLEANUP = 4;
type
PMonErrStruct = ^TMonErrStruct;
tagMONERRSTRUCT = packed record
cb: UINT;
wLastError: UINT;
dwTime: DWORD;
hTask: THandle;
end;
{$nonamespace tagMONERRSTRUCT}
TMonErrStruct = tagMONERRSTRUCT;
PMonLinkStruct = ^TMonLinkStruct;
tagMONLINKSTRUCT = packed record
cb: UINT;
dwTime: DWORD;
hTask: THandle;
fEstablished: BOOL;
fNoData: BOOL;
hszSvc: HSz;
hszTopic: HSz;
hszItem: HSz;
wFmt: UINT;
fServer: BOOL;
hConvServer: HConv;
hConvClient: HConv;
end;
{$nonamespace tagMONLINKSTRUCT}
TMonLinkStruct = tagMONLINKSTRUCT;
PMonConvStruct = ^TMonConvStruct;
tagMONCONVSTRUCT = packed record
cb: UINT;
fConnect: BOOL;
dwTime: DWORD;
hTask: THandle;
hszSvc: HSz;
hszTopic: HSz;
hConvClient: HConv;
hConvServer: HConv;
end;
{$nonamespace tagMONCONVSTRUCT}
TMonConvStruct = tagMONCONVSTRUCT;
const
MAX_MONITORS = 4;
APPCLASS_MONITOR = 1;
XTYP_MONITOR = $00F0 or XCLASS_NOTIFICATION or XTYPF_NOBLOCK;
{ Callback filter flags for use with MONITOR apps - 0 implies no monitor
callbacks. }
const
MF_HSZ_INFO = $01000000;
MF_SENDMSGS = $02000000;
MF_POSTMSGS = $04000000;
MF_CALLBACKS = $08000000;
MF_ERRORS = $10000000;
MF_LINKS = $20000000;
MF_CONV = $40000000;
ddelib = 'user32.dll';
implementation
function DdeInitializeA; external ddelib name 'DdeInitializeA';
function DdeInitializeW; external ddelib name 'DdeInitializeW';
function DdeInitialize; external ddelib name 'DdeInitializeA';
function DdeUninitialize; external ddelib name 'DdeUninitialize';
function DdeConnectList; external ddelib name 'DdeConnectList';
function DdeQueryNextServer; external ddelib name 'DdeQueryNextServer';
function DdeDisconnectList; external ddelib name 'DdeDisconnectList';
function DdeConnect; external ddelib name 'DdeConnect';
function DdeDisconnect; external ddelib name 'DdeDisconnect';
function DdeReconnect; external ddelib name 'DdeReconnect';
function DdeQueryConvInfo; external ddelib name 'DdeQueryConvInfo';
function DdeSetUserHandle; external ddelib name 'DdeSetUserHandle';
function DdeAbandonTransaction; external ddelib name 'DdeAbandonTransaction';
function DdePostAdvise; external ddelib name 'DdePostAdvise';
function DdeEnableCallback; external ddelib name 'DdeEnableCallback';
function DdeNameService; external ddelib name 'DdeNameService';
function DdeClientTransaction; external ddelib name 'DdeClientTransaction';
function DdeCreateDataHandle; external ddelib name 'DdeCreateDataHandle';
function DdeAddData; external ddelib name 'DdeAddData';
function DdeGetData; external ddelib name 'DdeGetData';
function DdeAccessData; external ddelib name 'DdeAccessData';
function DdeUnaccessData; external ddelib name 'DdeUnaccessData';
function DdeFreeDataHandle; external ddelib name 'DdeFreeDataHandle';
function DdeGetLastError; external ddelib name 'DdeGetLastError';
function DdeCreateStringHandleA; external ddelib name 'DdeCreateStringHandleA';
function DdeCreateStringHandleW; external ddelib name 'DdeCreateStringHandleW';
function DdeCreateStringHandle; external ddelib name 'DdeCreateStringHandleA';
function DdeQueryStringA; external ddelib name 'DdeQueryStringA';
function DdeQueryStringW; external ddelib name 'DdeQueryStringW';
function DdeQueryString; external ddelib name 'DdeQueryStringA';
function DdeFreeStringHandle; external ddelib name 'DdeFreeStringHandle';
function DdeKeepStringHandle; external ddelib name 'DdeKeepStringHandle';
function DdeCmpStringHandles; external ddelib name 'DdeCmpStringHandles';
end.