jwadde.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. // $Id: JwaDde.pas,v 1.9 2005/09/06 16:36:50 marquardt Exp $
  43. {$IFNDEF JWA_INCLUDEMODE}
  44. unit JwaDde;
  45. {$WEAKPACKAGEUNIT}
  46. {$I jediapilib.inc}
  47. interface
  48. uses
  49. JwaWinNT, JwaWinType;
  50. {$ENDIF !JWA_INCLUDEMODE}
  51. {$IFDEF JWA_INTERFACESECTION}
  52. {$HPPEMIT ''}
  53. {$HPPEMIT '#include "Dde.h"'}
  54. {$HPPEMIT ''}
  55. // DDE window messages
  56. const
  57. WM_DDE_FIRST = $03E0;
  58. {$EXTERNALSYM WM_DDE_FIRST}
  59. WM_DDE_INITIATE = WM_DDE_FIRST;
  60. {$EXTERNALSYM WM_DDE_INITIATE}
  61. WM_DDE_TERMINATE = WM_DDE_FIRST + 1;
  62. {$EXTERNALSYM WM_DDE_TERMINATE}
  63. WM_DDE_ADVISE = WM_DDE_FIRST + 2;
  64. {$EXTERNALSYM WM_DDE_ADVISE}
  65. WM_DDE_UNADVISE = WM_DDE_FIRST + 3;
  66. {$EXTERNALSYM WM_DDE_UNADVISE}
  67. WM_DDE_ACK = WM_DDE_FIRST + 4;
  68. {$EXTERNALSYM WM_DDE_ACK}
  69. WM_DDE_DATA = WM_DDE_FIRST + 5;
  70. {$EXTERNALSYM WM_DDE_DATA}
  71. WM_DDE_REQUEST = WM_DDE_FIRST + 6;
  72. {$EXTERNALSYM WM_DDE_REQUEST}
  73. WM_DDE_POKE = WM_DDE_FIRST + 7;
  74. {$EXTERNALSYM WM_DDE_POKE}
  75. WM_DDE_EXECUTE = WM_DDE_FIRST + 8;
  76. {$EXTERNALSYM WM_DDE_EXECUTE}
  77. WM_DDE_LAST = WM_DDE_FIRST + 8;
  78. {$EXTERNALSYM WM_DDE_LAST}
  79. {*----------------------------------------------------------------------------
  80. | DDEACK structure
  81. |
  82. | Structure of wStatus (LOWORD(lParam)) in WM_DDE_ACK message
  83. | sent in response to a WM_DDE_DATA, WM_DDE_REQUEST, WM_DDE_POKE,
  84. | WM_DDE_ADVISE, or WM_DDE_UNADVISE message.
  85. |
  86. ----------------------------------------------------------------------------*}
  87. type
  88. DDEACK = record
  89. Flags: Word;
  90. // bAppReturnCode:8,
  91. // reserved:6,
  92. // fBusy:1,
  93. // fAck:1;
  94. end;
  95. {$EXTERNALSYM DDEACK}
  96. TDdeAck = DDEACK;
  97. PDdeAck = ^DDEACK;
  98. {*----------------------------------------------------------------------------
  99. | DDEADVISE structure
  100. |
  101. | WM_DDE_ADVISE parameter structure for hOptions (LOWORD(lParam))
  102. |
  103. ----------------------------------------------------------------------------*}
  104. type
  105. DDEADVICE = record
  106. Flags: Word;
  107. // reserved:14,
  108. // fDeferUpd:1,
  109. // fAckReq:1;
  110. cfFormat: Smallint;
  111. end;
  112. {$EXTERNALSYM DDEADVICE}
  113. TDdeAdvice = DDEADVICE;
  114. PDdeAdvice = ^DDEADVICE;
  115. {*----------------------------------------------------------------------------
  116. | DDEDATA structure
  117. |
  118. | WM_DDE_DATA parameter structure for hData (LOWORD(lParam)).
  119. | The actual size of this structure depends on the size of
  120. | the Value array.
  121. |
  122. ----------------------------------------------------------------------------*}
  123. type
  124. DDEDATA = record
  125. usFlags: Word;
  126. // unused:12,
  127. // fResponse:1,
  128. // fRelease:1,
  129. // reserved:1,
  130. // fAckReq:1;
  131. cfFormat: Smallint;
  132. Value: array [0..0] of Byte;
  133. end;
  134. {$EXTERNALSYM DDEDATA}
  135. TDdeData = DDEDATA;
  136. PDdeData = ^DDEDATA;
  137. {*----------------------------------------------------------------------------
  138. | DDEPOKE structure
  139. |
  140. | WM_DDE_POKE parameter structure for hData (LOWORD(lParam)).
  141. | The actual size of this structure depends on the size of
  142. | the Value array.
  143. |
  144. ----------------------------------------------------------------------------*}
  145. type
  146. DDEPOKE = record
  147. usFlags: Word;
  148. //unused:13, // Earlier versions of DDE.H incorrectly 12 unused bits.
  149. //fRelease:1,
  150. //fReserved:2;
  151. cfFormat: Smallint;
  152. Value: array [0..0] of Byte; // This member was named rgb[1] in previous
  153. // versions of DDE.H
  154. end;
  155. {$EXTERNALSYM DDEPOKE}
  156. TDdePoke = DDEPOKE;
  157. PDdePoke = ^DDEPOKE;
  158. {*----------------------------------------------------------------------------
  159. The following typedef's were used in previous versions of the Windows SDK.
  160. They are still valid. The above typedef's define exactly the same structures
  161. as those below. The above typedef names are recommended, however, as they
  162. are more meaningful.
  163. Note that the DDEPOKE structure typedef'ed in earlier versions of DDE.H did
  164. not correctly define the bit positions.
  165. ----------------------------------------------------------------------------*}
  166. type
  167. DDELN = record
  168. usFlags: Word;
  169. // unused:13,
  170. // fRelease:1,
  171. // fDeferUpd:1,
  172. // fAckReq:1;
  173. cfFormat: Smallint;
  174. end;
  175. {$EXTERNALSYM DDELN}
  176. TDdeLn = DDELN;
  177. PDdeLn = ^DDELN;
  178. DDEUP = record
  179. usFlags: Word;
  180. // unused:12,
  181. // fAck:1,
  182. // fRelease:1,
  183. // fReserved:1,
  184. // fAckReq:1;
  185. cfFormat: Smallint;
  186. rgb: array [0..0] of Byte;
  187. end;
  188. {$EXTERNALSYM DDEUP}
  189. TDdeUp = DDEUP;
  190. PDdeUp = ^DDEUP;
  191. //
  192. // DDE SECURITY
  193. //
  194. function DdeSetQualityOfService(hwndClient: HWND; const pqosNew: SECURITY_QUALITY_OF_SERVICE;
  195. pqosPrev: PSECURITY_QUALITY_OF_SERVICE): BOOL; stdcall;
  196. {$EXTERNALSYM DdeSetQualityOfService}
  197. function ImpersonateDdeClientWindow(hWndClient, hWndServer: HWND): BOOL; stdcall;
  198. {$EXTERNALSYM ImpersonateDdeClientWindow}
  199. //
  200. // DDE message packing APIs
  201. //
  202. function PackDDElParam(msg: UINT; uiLo, uiHi: UINT_PTR): LPARAM; stdcall;
  203. {$EXTERNALSYM PackDDElParam}
  204. function UnpackDDElParam(msg: UINT; lParam: LPARAM; puiLo, puiHi: PUINT_PTR): BOOL; stdcall;
  205. {$EXTERNALSYM UnpackDDElParam}
  206. function FreeDDElParam(msg: UINT; lParam: LPARAM): BOOL; stdcall;
  207. {$EXTERNALSYM FreeDDElParam}
  208. function ReuseDDElParam(lParam: LPARAM; msgIn, msgOut: UINT; uiLo, uiHi: UINT_PTR): LPARAM; stdcall;
  209. {$EXTERNALSYM ReuseDDElParam}
  210. {$ENDIF JWA_INTERFACESECTION}
  211. {$IFNDEF JWA_INCLUDEMODE}
  212. implementation
  213. uses
  214. JwaWinDLLNames;
  215. {$ENDIF !JWA_INCLUDEMODE}
  216. {$IFDEF JWA_IMPLEMENTATIONSECTION}
  217. {$IFDEF DYNAMIC_LINK}
  218. var
  219. _DdeSetQualityOfService: Pointer;
  220. function DdeSetQualityOfService;
  221. begin
  222. GetProcedureAddress(_DdeSetQualityOfService, user32, 'DdeSetQualityOfService');
  223. asm
  224. MOV ESP, EBP
  225. POP EBP
  226. JMP [_DdeSetQualityOfService]
  227. end;
  228. end;
  229. var
  230. _ImpersonateDdeClientWindow: Pointer;
  231. function ImpersonateDdeClientWindow;
  232. begin
  233. GetProcedureAddress(_ImpersonateDdeClientWindow, user32, 'ImpersonateDdeClientWindow');
  234. asm
  235. MOV ESP, EBP
  236. POP EBP
  237. JMP [_ImpersonateDdeClientWindow]
  238. end;
  239. end;
  240. var
  241. _PackDDElParam: Pointer;
  242. function PackDDElParam;
  243. begin
  244. GetProcedureAddress(_PackDDElParam, user32, 'PackDDElParam');
  245. asm
  246. MOV ESP, EBP
  247. POP EBP
  248. JMP [_PackDDElParam]
  249. end;
  250. end;
  251. var
  252. _UnpackDDElParam: Pointer;
  253. function UnpackDDElParam;
  254. begin
  255. GetProcedureAddress(_UnpackDDElParam, user32, 'UnpackDDElParam');
  256. asm
  257. MOV ESP, EBP
  258. POP EBP
  259. JMP [_UnpackDDElParam]
  260. end;
  261. end;
  262. var
  263. _FreeDDElParam: Pointer;
  264. function FreeDDElParam;
  265. begin
  266. GetProcedureAddress(_FreeDDElParam, user32, 'FreeDDElParam');
  267. asm
  268. MOV ESP, EBP
  269. POP EBP
  270. JMP [_FreeDDElParam]
  271. end;
  272. end;
  273. var
  274. _ReuseDDElParam: Pointer;
  275. function ReuseDDElParam;
  276. begin
  277. GetProcedureAddress(_ReuseDDElParam, user32, 'ReuseDDElParam');
  278. asm
  279. MOV ESP, EBP
  280. POP EBP
  281. JMP [_ReuseDDElParam]
  282. end;
  283. end;
  284. {$ELSE}
  285. function DdeSetQualityOfService; external user32 name 'DdeSetQualityOfService';
  286. function ImpersonateDdeClientWindow; external user32 name 'ImpersonateDdeClientWindow';
  287. function PackDDElParam; external user32 name 'PackDDElParam';
  288. function UnpackDDElParam; external user32 name 'UnpackDDElParam';
  289. function FreeDDElParam; external user32 name 'FreeDDElParam';
  290. function ReuseDDElParam; external user32 name 'ReuseDDElParam';
  291. {$ENDIF DYNAMIC_LINK}
  292. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  293. {$IFNDEF JWA_INCLUDEMODE}
  294. end.
  295. {$ENDIF !JWA_INCLUDEMODE}