jwacpl.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. {******************************************************************************}
  2. { }
  3. { Control Panel Applets 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: cpl.h, released June 2000. The original Pascal }
  9. { code is: Cpl.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 JwaCpl;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "cpl.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinUser, JwaWinType;
  51. //
  52. // General rules for being installed in the Control Panel:
  53. //
  54. // 1) The DLL must export a function named CPlApplet which will handle
  55. // the messages discussed below.
  56. // 2) If the applet needs to save information in CONTROL.INI minimize
  57. // clutter by using the application name [MMCPL.appletname].
  58. // 2) If the applet is refrenced in CONTROL.INI under [MMCPL] use
  59. // the following form:
  60. // ...
  61. // [MMCPL]
  62. // uniqueName=c:\mydir\myapplet.dll
  63. // ...
  64. //
  65. //
  66. // The order applet DLL's are loaded by CONTROL.EXE is not guaranteed.
  67. // Control panels may be sorted for display, etc.
  68. //
  69. //
  70. // #include <pshpack1.h> // Assume byte packing throughout
  71. //
  72. // CONTROL.EXE will answer this message and launch an applet
  73. //
  74. // WM_CPL_LAUNCH
  75. //
  76. // wParam - window handle of calling app
  77. // lParam - LPTSTR of name of applet to launch
  78. //
  79. // WM_CPL_LAUNCHED
  80. //
  81. // wParam - TRUE/FALSE if applet was launched
  82. // lParam - NULL
  83. //
  84. // CONTROL.EXE will post this message to the caller when the applet returns
  85. // (ie., when wParam is a valid window handle)
  86. //
  87. //
  88. const
  89. WM_CPL_LAUNCH = WM_USER + 1000;
  90. {$EXTERNALSYM WM_CPL_LAUNCH}
  91. WM_CPL_LAUNCHED = WM_USER + 1001;
  92. {$EXTERNALSYM WM_CPL_LAUNCHED}
  93. // A function prototype for CPlApplet()
  94. type
  95. APPLET_PROC = function(hwndCpl: HWND; msg: UINT;
  96. lParam1, lParam2: LPARAM): LONG; stdcall;
  97. {$EXTERNALSYM APPLET_PROC}
  98. TCPLApplet = APPLET_PROC;
  99. // The data structure CPlApplet() must fill in.
  100. LPCPLINFO = ^CPLINFO;
  101. {$EXTERNALSYM LPCPLINFO}
  102. tagCPLINFO = packed record
  103. idIcon: Integer; // icon resource id, provided by CPlApplet()
  104. idName: Integer; // name string res. id, provided by CPlApplet()
  105. idInfo: Integer; // info string res. id, provided by CPlApplet()
  106. lData: LONG_PTR; // user defined data
  107. end;
  108. {$EXTERNALSYM tagCPLINFO}
  109. CPLINFO = tagCPLINFO;
  110. {$EXTERNALSYM CPLINFO}
  111. TCplInfo = CPLINFO;
  112. PCplInfo = LPCPLINFO;
  113. LPNEWCPLINFOA = ^NEWCPLINFOA;
  114. {$EXTERNALSYM LPNEWCPLINFOA}
  115. tagNEWCPLINFOA = packed record
  116. dwSize: DWORD; // similar to the commdlg
  117. dwFlags: DWORD;
  118. dwHelpContext: DWORD; // help context to use
  119. lData: LONG_PTR; // user defined data
  120. hIcon: HICON; // icon to use, this is owned by CONTROL.EXE (may be deleted)
  121. szName: array [0..31] of CHAR; // short name
  122. szInfo: array [0..63] of CHAR; // long name (status line)
  123. szHelpFile: array [0..127] of CHAR; // path to help file to use
  124. end;
  125. {$EXTERNALSYM tagNEWCPLINFOA}
  126. NEWCPLINFOA = tagNEWCPLINFOA;
  127. {$EXTERNALSYM NEWCPLINFOA}
  128. TNewCplInfoA = NEWCPLINFOA;
  129. PNewCplInfoA = LPNEWCPLINFOA;
  130. LPNEWCPLINFOW = ^NEWCPLINFOW;
  131. {$EXTERNALSYM LPNEWCPLINFOW}
  132. tagNEWCPLINFOW = packed record
  133. dwSize: DWORD; // similar to the commdlg
  134. dwFlags: DWORD;
  135. dwHelpContext: DWORD; // help context to use
  136. lData: LONG_PTR; // user defined data
  137. hIcon: HICON; // icon to use, this is owned by CONTROL.EXE (may be deleted)
  138. szName: array [0..31] of WCHAR; // short name
  139. szInfo: array [0..63] of WCHAR; // long name (status line)
  140. szHelpFile: array [0..127] of WCHAR; // path to help file to use
  141. end;
  142. {$EXTERNALSYM tagNEWCPLINFOW}
  143. NEWCPLINFOW = tagNEWCPLINFOW;
  144. {$EXTERNALSYM NEWCPLINFOW}
  145. TNewCplInfoW = NEWCPLINFOW;
  146. PNewCplInfoW = LPNEWCPLINFOW;
  147. {$IFDEF UNICODE}
  148. NEWCPLINFO = NEWCPLINFOW;
  149. {$EXTERNALSYM NEWCPLINFO}
  150. LPNEWCPLINFO = LPNEWCPLINFOW;
  151. {$EXTERNALSYM LPNEWCPLINFO}
  152. TNewCplInfo = TNewCplInfoW;
  153. PNewCplInfo = PNewCplInfoW;
  154. {$ELSE}
  155. NEWCPLINFO = NEWCPLINFOA;
  156. {$EXTERNALSYM NEWCPLINFO}
  157. LPNEWCPLINFO = LPNEWCPLINFOA;
  158. {$EXTERNALSYM LPNEWCPLINFO}
  159. TNewCplInfo = TNewCplInfoA;
  160. PNewCplInfo = PNewCplInfoA;
  161. {$ENDIF UNICODE}
  162. const
  163. CPL_DYNAMIC_RES = 0;
  164. {$EXTERNALSYM CPL_DYNAMIC_RES}
  165. // This constant may be used in place of real resource IDs for the idIcon,
  166. // idName or idInfo members of the CPLINFO structure. Normally, the system
  167. // uses these values to extract copies of the resources and store them in a
  168. // cache. Once the resource information is in the cache, the system does not
  169. // need to load a CPL unless the user actually tries to use it.
  170. // CPL_DYNAMIC_RES tells the system not to cache the resource, but instead to
  171. // load the CPL every time it needs to display information about an item. This
  172. // allows a CPL to dynamically decide what information will be displayed, but
  173. // is SIGNIFICANTLY SLOWER than displaying information from a cache.
  174. // Typically, CPL_DYNAMIC_RES is used when a control panel must inspect the
  175. // runtime status of some device in order to provide text or icons to display.
  176. // The messages CPlApplet() must handle:
  177. CPL_INIT = 1;
  178. {$EXTERNALSYM CPL_INIT}
  179. // This message is sent to indicate CPlApplet() was found.
  180. // lParam1 and lParam2 are not defined.
  181. // Return TRUE or FALSE indicating whether the control panel should proceed.
  182. CPL_GETCOUNT = 2;
  183. {$EXTERNALSYM CPL_GETCOUNT}
  184. // This message is sent to determine the number of applets to be displayed.
  185. // lParam1 and lParam2 are not defined.
  186. // Return the number of applets you wish to display in the control
  187. // panel window.
  188. CPL_INQUIRE = 3;
  189. {$EXTERNALSYM CPL_INQUIRE}
  190. // This message is sent for information about each applet.
  191. // A CPL SHOULD HANDLE BOTH THE CPL_INQUIRE AND CPL_NEWINQUIRE MESSAGES.
  192. // The developer must not make any assumptions about the order or dependance
  193. // of CPL inquiries.
  194. // lParam1 is the applet number to register, a value from 0 to
  195. // (CPL_GETCOUNT - 1). lParam2 is a far ptr to a CPLINFO structure.
  196. // Fill in CPLINFO's idIcon, idName, idInfo and lData fields with
  197. // the resource id for an icon to display, name and description string ids,
  198. // and a long data item associated with applet #lParam1. This information
  199. // may be cached by the caller at runtime and/or across sessions.
  200. // To prevent caching, see CPL_DYNAMIC_RES, above.
  201. CPL_SELECT = 4;
  202. {$EXTERNALSYM CPL_SELECT}
  203. // The CPL_SELECT message has been deleted.
  204. CPL_DBLCLK = 5;
  205. {$EXTERNALSYM CPL_DBLCLK}
  206. // This message is sent when the applet's icon has been double-clicked
  207. // upon. lParam1 is the applet number which was selected. lParam2 is the
  208. // applet's lData value.
  209. // This message should initiate the applet's dialog box.
  210. CPL_STOP = 6;
  211. {$EXTERNALSYM CPL_STOP}
  212. // This message is sent for each applet when the control panel is exiting.
  213. // lParam1 is the applet number. lParam2 is the applet's lData value.
  214. // Do applet specific cleaning up here.
  215. CPL_EXIT = 7;
  216. {$EXTERNALSYM CPL_EXIT}
  217. // This message is sent just before the control panel calls FreeLibrary.
  218. // lParam1 and lParam2 are not defined.
  219. // Do non-applet specific cleaning up here.
  220. CPL_NEWINQUIRE = 8;
  221. {$EXTERNALSYM CPL_NEWINQUIRE}
  222. // Same as CPL_INQUIRE execpt lParam2 is a pointer to a NEWCPLINFO struct.
  223. // A CPL SHOULD HANDLE BOTH THE CPL_INQUIRE AND CPL_NEWINQUIRE MESSAGES.
  224. // The developer must not make any assumptions about the order or dependance
  225. // of CPL inquiries.
  226. CPL_STARTWPARMSA = 9;
  227. {$EXTERNALSYM CPL_STARTWPARMSA}
  228. CPL_STARTWPARMSW = 10;
  229. {$EXTERNALSYM CPL_STARTWPARMSW}
  230. {$IFDEF UNICODE}
  231. CPL_STARTWPARMS = CPL_STARTWPARMSW;
  232. {$EXTERNALSYM CPL_STARTWPARMS}
  233. {$ELSE}
  234. CPL_STARTWPARMS = CPL_STARTWPARMSA;
  235. {$EXTERNALSYM CPL_STARTWPARMS}
  236. {$ENDIF UNICODE}
  237. // this message parallels CPL_DBLCLK in that the applet should initiate
  238. // its dialog box. where it differs is that this invocation is coming
  239. // out of RUNDLL, and there may be some extra directions for execution.
  240. // lParam1: the applet number.
  241. // lParam2: an LPSTR to any extra directions that might exist.
  242. // returns: TRUE if the message was handled; FALSE if not.
  243. // This message is internal to the Control Panel and MAIN applets.
  244. // It is only sent when an applet is invoked from the Command line
  245. // during system installation.
  246. CPL_SETUP = 200;
  247. {$EXTERNALSYM CPL_SETUP}
  248. implementation
  249. end.