jwacpl.pas 11 KB

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