jwadde.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. {******************************************************************************}
  2. { }
  3. { Dynamic Data Exchange API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: dde.h, released June 2000. The original Pascal }
  9. { code is: Dde.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaDde;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "Dde.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinNT, JwaWinType;
  51. // DDE window messages
  52. const
  53. WM_DDE_FIRST = $03E0;
  54. {$EXTERNALSYM WM_DDE_FIRST}
  55. WM_DDE_INITIATE = WM_DDE_FIRST;
  56. {$EXTERNALSYM WM_DDE_INITIATE}
  57. WM_DDE_TERMINATE = WM_DDE_FIRST + 1;
  58. {$EXTERNALSYM WM_DDE_TERMINATE}
  59. WM_DDE_ADVISE = WM_DDE_FIRST + 2;
  60. {$EXTERNALSYM WM_DDE_ADVISE}
  61. WM_DDE_UNADVISE = WM_DDE_FIRST + 3;
  62. {$EXTERNALSYM WM_DDE_UNADVISE}
  63. WM_DDE_ACK = WM_DDE_FIRST + 4;
  64. {$EXTERNALSYM WM_DDE_ACK}
  65. WM_DDE_DATA = WM_DDE_FIRST + 5;
  66. {$EXTERNALSYM WM_DDE_DATA}
  67. WM_DDE_REQUEST = WM_DDE_FIRST + 6;
  68. {$EXTERNALSYM WM_DDE_REQUEST}
  69. WM_DDE_POKE = WM_DDE_FIRST + 7;
  70. {$EXTERNALSYM WM_DDE_POKE}
  71. WM_DDE_EXECUTE = WM_DDE_FIRST + 8;
  72. {$EXTERNALSYM WM_DDE_EXECUTE}
  73. WM_DDE_LAST = WM_DDE_FIRST + 8;
  74. {$EXTERNALSYM WM_DDE_LAST}
  75. {*----------------------------------------------------------------------------
  76. | DDEACK structure
  77. |
  78. | Structure of wStatus (LOWORD(lParam)) in WM_DDE_ACK message
  79. | sent in response to a WM_DDE_DATA, WM_DDE_REQUEST, WM_DDE_POKE,
  80. | WM_DDE_ADVISE, or WM_DDE_UNADVISE message.
  81. |
  82. ----------------------------------------------------------------------------*}
  83. type
  84. DDEACK = record
  85. Flags: Word;
  86. // bAppReturnCode:8,
  87. // reserved:6,
  88. // fBusy:1,
  89. // fAck:1;
  90. end;
  91. {$EXTERNALSYM DDEACK}
  92. TDdeAck = DDEACK;
  93. PDdeAck = ^DDEACK;
  94. {*----------------------------------------------------------------------------
  95. | DDEADVISE structure
  96. |
  97. | WM_DDE_ADVISE parameter structure for hOptions (LOWORD(lParam))
  98. |
  99. ----------------------------------------------------------------------------*}
  100. type
  101. DDEADVICE = record
  102. Flags: Word;
  103. // reserved:14,
  104. // fDeferUpd:1,
  105. // fAckReq:1;
  106. cfFormat: Smallint;
  107. end;
  108. {$EXTERNALSYM DDEADVICE}
  109. TDdeAdvice = DDEADVICE;
  110. PDdeAdvice = ^DDEADVICE;
  111. {*----------------------------------------------------------------------------
  112. | DDEDATA structure
  113. |
  114. | WM_DDE_DATA parameter structure for hData (LOWORD(lParam)).
  115. | The actual size of this structure depends on the size of
  116. | the Value array.
  117. |
  118. ----------------------------------------------------------------------------*}
  119. type
  120. DDEDATA = record
  121. usFlags: Word;
  122. // unused:12,
  123. // fResponse:1,
  124. // fRelease:1,
  125. // reserved:1,
  126. // fAckReq:1;
  127. cfFormat: Smallint;
  128. Value: array [0..0] of Byte;
  129. end;
  130. {$EXTERNALSYM DDEDATA}
  131. TDdeData = DDEDATA;
  132. PDdeData = ^DDEDATA;
  133. {*----------------------------------------------------------------------------
  134. | DDEPOKE structure
  135. |
  136. | WM_DDE_POKE parameter structure for hData (LOWORD(lParam)).
  137. | The actual size of this structure depends on the size of
  138. | the Value array.
  139. |
  140. ----------------------------------------------------------------------------*}
  141. type
  142. DDEPOKE = record
  143. usFlags: Word;
  144. //unused:13, // Earlier versions of DDE.H incorrectly 12 unused bits.
  145. //fRelease:1,
  146. //fReserved:2;
  147. cfFormat: Smallint;
  148. Value: array [0..0] of Byte; // This member was named rgb[1] in previous
  149. // versions of DDE.H
  150. end;
  151. {$EXTERNALSYM DDEPOKE}
  152. TDdePoke = DDEPOKE;
  153. PDdePoke = ^DDEPOKE;
  154. {*----------------------------------------------------------------------------
  155. The following typedef's were used in previous versions of the Windows SDK.
  156. They are still valid. The above typedef's define exactly the same structures
  157. as those below. The above typedef names are recommended, however, as they
  158. are more meaningful.
  159. Note that the DDEPOKE structure typedef'ed in earlier versions of DDE.H did
  160. not correctly define the bit positions.
  161. ----------------------------------------------------------------------------*}
  162. type
  163. DDELN = record
  164. usFlags: Word;
  165. // unused:13,
  166. // fRelease:1,
  167. // fDeferUpd:1,
  168. // fAckReq:1;
  169. cfFormat: Smallint;
  170. end;
  171. {$EXTERNALSYM DDELN}
  172. TDdeLn = DDELN;
  173. PDdeLn = ^DDELN;
  174. DDEUP = record
  175. usFlags: Word;
  176. // unused:12,
  177. // fAck:1,
  178. // fRelease:1,
  179. // fReserved:1,
  180. // fAckReq:1;
  181. cfFormat: Smallint;
  182. rgb: array [0..0] of Byte;
  183. end;
  184. {$EXTERNALSYM DDEUP}
  185. TDdeUp = DDEUP;
  186. PDdeUp = ^DDEUP;
  187. //
  188. // DDE SECURITY
  189. //
  190. function DdeSetQualityOfService(hwndClient: HWND; const pqosNew: SECURITY_QUALITY_OF_SERVICE;
  191. pqosPrev: PSECURITY_QUALITY_OF_SERVICE): BOOL; stdcall;
  192. {$EXTERNALSYM DdeSetQualityOfService}
  193. function ImpersonateDdeClientWindow(hWndClient, hWndServer: HWND): BOOL; stdcall;
  194. {$EXTERNALSYM ImpersonateDdeClientWindow}
  195. //
  196. // DDE message packing APIs
  197. //
  198. function PackDDElParam(msg: UINT; uiLo, uiHi: UINT_PTR): LPARAM; stdcall;
  199. {$EXTERNALSYM PackDDElParam}
  200. function UnpackDDElParam(msg: UINT; lParam: LPARAM; puiLo, puiHi: PUINT_PTR): BOOL; stdcall;
  201. {$EXTERNALSYM UnpackDDElParam}
  202. function FreeDDElParam(msg: UINT; lParam: LPARAM): BOOL; stdcall;
  203. {$EXTERNALSYM FreeDDElParam}
  204. function ReuseDDElParam(lParam: LPARAM; msgIn, msgOut: UINT; uiLo, uiHi: UINT_PTR): LPARAM; stdcall;
  205. {$EXTERNALSYM ReuseDDElParam}
  206. implementation
  207. const
  208. user32 = 'user32.dll';
  209. {$IFDEF DYNAMIC_LINK}
  210. var
  211. _DdeSetQualityOfService: Pointer;
  212. function DdeSetQualityOfService;
  213. begin
  214. GetProcedureAddress(_DdeSetQualityOfService, user32, 'DdeSetQualityOfService');
  215. asm
  216. MOV ESP, EBP
  217. POP EBP
  218. JMP [_DdeSetQualityOfService]
  219. end;
  220. end;
  221. var
  222. _ImpersonateDdeClientWindow: Pointer;
  223. function ImpersonateDdeClientWindow;
  224. begin
  225. GetProcedureAddress(_ImpersonateDdeClientWindow, user32, 'ImpersonateDdeClientWindow');
  226. asm
  227. MOV ESP, EBP
  228. POP EBP
  229. JMP [_ImpersonateDdeClientWindow]
  230. end;
  231. end;
  232. var
  233. _PackDDElParam: Pointer;
  234. function PackDDElParam;
  235. begin
  236. GetProcedureAddress(_PackDDElParam, user32, 'PackDDElParam');
  237. asm
  238. MOV ESP, EBP
  239. POP EBP
  240. JMP [_PackDDElParam]
  241. end;
  242. end;
  243. var
  244. _UnpackDDElParam: Pointer;
  245. function UnpackDDElParam;
  246. begin
  247. GetProcedureAddress(_UnpackDDElParam, user32, 'UnpackDDElParam');
  248. asm
  249. MOV ESP, EBP
  250. POP EBP
  251. JMP [_UnpackDDElParam]
  252. end;
  253. end;
  254. var
  255. _FreeDDElParam: Pointer;
  256. function FreeDDElParam;
  257. begin
  258. GetProcedureAddress(_FreeDDElParam, user32, 'FreeDDElParam');
  259. asm
  260. MOV ESP, EBP
  261. POP EBP
  262. JMP [_FreeDDElParam]
  263. end;
  264. end;
  265. var
  266. _ReuseDDElParam: Pointer;
  267. function ReuseDDElParam;
  268. begin
  269. GetProcedureAddress(_ReuseDDElParam, user32, 'ReuseDDElParam');
  270. asm
  271. MOV ESP, EBP
  272. POP EBP
  273. JMP [_ReuseDDElParam]
  274. end;
  275. end;
  276. {$ELSE}
  277. function DdeSetQualityOfService; external user32 name 'DdeSetQualityOfService';
  278. function ImpersonateDdeClientWindow; external user32 name 'ImpersonateDdeClientWindow';
  279. function PackDDElParam; external user32 name 'PackDDElParam';
  280. function UnpackDDElParam; external user32 name 'UnpackDDElParam';
  281. function FreeDDElParam; external user32 name 'FreeDDElParam';
  282. function ReuseDDElParam; external user32 name 'ReuseDDElParam';
  283. {$ENDIF DYNAMIC_LINK}
  284. end.