pmshl.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by Yuri Prokushev ([email protected]).
  4. OS/2 Presentation Manager Shell constants, types, messages and
  5. function declarations.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {Warning: This code is alfa. Future versions
  13. of this unit might not be compatible.}
  14. {$IFNDEF FPC_DOTTEDUNITS}
  15. unit pmshl;
  16. {$ENDIF FPC_DOTTEDUNITS}
  17. Interface
  18. {$IFDEF FPC_DOTTEDUNITS}
  19. uses
  20. OS2Api.os2def, OS2Api.pmwin;
  21. {$ELSE FPC_DOTTEDUNITS}
  22. uses
  23. Os2Def, PmWin;
  24. {$ENDIF FPC_DOTTEDUNITS}
  25. // common types, constants and function declarations
  26. // maximum title length
  27. const
  28. MaxNameL=60;
  29. // program handle
  30. type
  31. HProgram=Cardinal; // hprog
  32. PHProgram=^HProgram;
  33. HAPP=Cardinal;
  34. // ini file handle
  35. type
  36. HINI=Cardinal; // hini
  37. PHINI=^HINI;
  38. const
  39. HINI_PROFILE = 0;
  40. HINI_USERPROFILE =-1;
  41. HINI_SYSTEMPROFILE =-2;
  42. HINI_USER = HINI_USERPROFILE;
  43. HINI_SYSTEM = HINI_SYSTEMPROFILE;
  44. type
  45. PPrfProfile=^PrfProfile;
  46. PrfProfile=record // prfpro
  47. cchUserName: Cardinal;
  48. pszUserName: PAnsiChar;
  49. cchSysName: Cardinal;
  50. pszSysName: PAnsiChar;
  51. end;
  52. // program list section
  53. // maximum path length
  54. const
  55. MAXPATHL=128;
  56. // root group handle
  57. const
  58. SGH_ROOT = -1;
  59. type
  60. PHPROGARRAY=^HPROGARRAY;
  61. HPROGARRAY=record // hpga
  62. ahprog: Array[1..1] of HProgram;
  63. end;
  64. PROGCATEGORY=Cardinal; // progc
  65. PPROGCATEGORY=^PROGCATEGORY;
  66. // values acceptable for PROGCATEGORY for PM groups
  67. const
  68. PROG_DEFAULT =0;
  69. PROG_FULLSCREEN =1;
  70. PROG_WINDOWABLEVIO =2;
  71. PROG_PM =3;
  72. PROG_GROUP =5;
  73. PROG_REAL =4;
  74. PROG_VDM =4;
  75. PROG_WINDOWEDVDM =7;
  76. PROG_DLL =6;
  77. PROG_PDD =8;
  78. PROG_VDD =9;
  79. PROG_WINDOW_REAL =10;
  80. PROG_WINDOW_PROT =11;
  81. PROG_30_STD =11;
  82. PROG_WINDOW_AUTO =12;
  83. PROG_SEAMLESSVDM =13;
  84. PROG_30_STDSEAMLESSVDM =13;
  85. PROG_SEAMLESSCOMMON =14;
  86. PROG_30_STDSEAMLESSCOMMON =14;
  87. PROG_31_STDSEAMLESSVDM =15;
  88. PROG_31_STDSEAMLESSCOMMON =16;
  89. PROG_31_ENHSEAMLESSVDM =17;
  90. PROG_31_ENHSEAMLESSCOMMON =18;
  91. PROG_31_ENH =19;
  92. PROG_31_STD =20;
  93. PROG_DOS_GAME =21;
  94. PROG_WIN_GAME =22;
  95. PROG_DOS_MODE =23;
  96. PROG_RESERVED =255;
  97. type
  98. PProgType=^ProgType;
  99. ProgType=record // progt
  100. progc: ProgCategory;
  101. fbVisible: Cardinal;
  102. end;
  103. // visibility flag for PROGTYPE structure
  104. const
  105. SHE_VISIBLE = $00;
  106. SHE_INVISIBLE = $01;
  107. SHE_RESERVED = $FF;
  108. // Protected group flag for PROGTYPE structure
  109. const
  110. SHE_UNPROTECTED =$00;
  111. SHE_PROTECTED =$02;
  112. // Structures associated with 'Prf' calls
  113. type
  114. PPROGDETAILS=^PROGDETAILS;
  115. PROGDETAILS=record // progde
  116. Length: Cardinal; // set this to sizeof(PROGDETAILS)
  117. progt: ProgType;
  118. pszTitle: PAnsiChar; // any of the pointers can be NULL
  119. pszExecutable: PAnsiChar;
  120. pszParameters: PAnsiChar;
  121. pszStartupDir: PAnsiChar;
  122. pszIcon: PAnsiChar;
  123. pszEnvironment: PAnsiChar; // this is terminated by /0/0
  124. swpInitial: SWP; // this replaces XYWINSIZE
  125. end;
  126. PPROGTITLE=^PROGTITLE;
  127. PROGTITLE=record // progti
  128. hprog: HProgram;
  129. progt: ProgType;
  130. pszTitle: PAnsiChar;
  131. End;
  132. // Program List API Function Definitions
  133. // Program List API available 'Prf' calls
  134. Function PrfQueryProgramTitles(ahini: HINI; hprogGroup: HProgram;
  135. var pTitles: PROGTITLE; cchBufferMax: Cardinal;
  136. var pulCount: Cardinal): Cardinal; cdecl;
  137. external 'PMSHAPI' index 113;
  138. //*********************************************************************/
  139. //* NOTE: string information is concatanated after the array of */
  140. //* PROGTITLE structures so you need to allocate storage */
  141. //* greater than sizeof(PROGTITLE)*cPrograms to query programs */
  142. //* in a group. */
  143. //* */
  144. //* PrfQueryProgramTitles recommended usage to obtain titles of all */
  145. //* programs in a group (Hgroup=SGH_ROOT is for all groups): */
  146. //* */
  147. //* BufLen = PrfQueryProgramTitles(Hini, Hgroup, */
  148. //* (PPROGTITLE)NULL, 0, &Count); */
  149. //* */
  150. //* Alocate buffer of Buflen */
  151. //* */
  152. //* Len = PrfQueryProgramTitles(Hini, Hgroup, (PPROGTITLE)pBuffer, */
  153. //* BufLen, pCount); */
  154. //* */
  155. //*********************************************************************/
  156. Function PrfAddProgram(ahini: HINI; var pDetails: PROGDETAILS;
  157. hprogGroup: HProgram): HProgram; cdecl;
  158. external 'PMSHAPI' index 109;
  159. Function PrfChangeProgram(ahini: HINI;hprog: HProgram;
  160. var pDetails: PROGDETAILS): Longbool; cdecl;
  161. external 'PMSHAPI' index 110;
  162. Function PrfQueryDefinition(ahini: HINI; hprog: HProgram;
  163. var pDetails: PROGDETAILS;
  164. cchBufferMax: Cardinal): Cardinal; cdecl;
  165. external 'PMSHAPI' index 111;
  166. //*********************************************************************/
  167. //* NOTE: string information is concatanated after the PROGDETAILS */
  168. //* field structure so you need to allocate storage greater */
  169. //* than sizeof(PROGDETAILS) to query programs */
  170. //* */
  171. //* PrfQueryDefinition recomended usage: */
  172. //* */
  173. //* bufferlen = PrfQueryDefinition(Hini,Hprog,(PPROGDETAILS)NULL,0) */
  174. //* */
  175. //* Alocate buffer of bufferlen bytes */
  176. //* set Length field (0 will be supported) */
  177. //* */
  178. //* (PPROGDETAILS)pBuffer->Length=sizeof(PPROGDETAILS) */
  179. //* */
  180. //* len = PrfQueryDefinition(Hini, Hprog, (PPROGDETAILS)pBuffer, */
  181. //* bufferlen) */
  182. //*********************************************************************/
  183. Function PrfRemoveProgram(ahini: HINI; hprog: HProgram): Longbool; cdecl;
  184. external 'PMSHAPI' index 104;
  185. Function PrfQueryProgramHandle(ahini: HINI; const pszExe: PAnsiChar;
  186. aphprogArray: HPROGARRAY; cchBufferMax: Cardinal;
  187. var pulCount: Cardinal): Longbool; cdecl;
  188. external 'PMSHAPI' index 58;
  189. Function PrfCreateGroup(ahini: HINI; const pszTitle: PAnsiChar;
  190. chVisibility: Byte): HProgram; cdecl;
  191. external 'PMSHAPI' index 55;
  192. Function PrfDestroyGroup(ahini: HINI; hprogGroup: HProgram): Longbool; cdecl;
  193. external 'PMSHAPI' index 106;
  194. Function PrfQueryProgramCategory(ahini: HINI; const pszExe: PAnsiChar): PROGCATEGORY; cdecl;
  195. external 'PMSHAPI' index 59;
  196. Function WinStartApp(hwndNotify: HWND; var pDetails: PROGDETAILS; const pszParams: PAnsiChar;
  197. Reserved: Pointer; fbOptions: Cardinal): HAPP; cdecl;
  198. external 'PMSHAPI' index 119;
  199. // bit values for Options parameter
  200. const
  201. SAF_VALIDFLAGS =$001F;
  202. SAF_INSTALLEDCMDLINE =$0001; // use installed parameters
  203. SAF_STARTCHILDAPP =$0002; // related application
  204. SAF_MAXIMIZED =$0004; // Start App maximized
  205. SAF_MINIMIZED =$0008; // Start App minimized, if !SAF_MAXIMIZED
  206. SAF_BACKGROUND =$0010; // Start app in the background
  207. Function WinTerminateApp(ahapp: HAPP): Longbool; cdecl;
  208. external 'PMSHAPI' index 130;
  209. // switch list section
  210. type
  211. HSWITCH=Cardinal; // hsw
  212. PHSWITCH=^HSWITCH;
  213. PSWCNTRL=^SWCNTRL;
  214. SWCNTRL=record // swctl
  215. hwnd_: HWND;
  216. hwndIcon: HWND;
  217. hprog: HProgram;
  218. idProcess: Cardinal;
  219. idSession: Cardinal;
  220. uchVisibility: Cardinal;
  221. fbJump: Cardinal;
  222. szSwtitle: Array[1..MaxNameL+4] of AnsiChar;
  223. bProgType: Cardinal;
  224. end;
  225. // visibility flag for SWCNTRL structure
  226. const
  227. SWL_VISIBLE =$04;
  228. SWL_INVISIBLE =$01;
  229. SWL_GRAYED =$02;
  230. // jump flag for SWCNTRL structure
  231. const
  232. SWL_JUMPABLE =$02;
  233. SWL_NOTJUMPABLE =$01;
  234. // Switching Program functions
  235. Function WinAddSwitchEntry(VAR aps: SWCNTRL): HSWITCH; cdecl;
  236. external 'PMSHAPI' index 120;
  237. Function WinRemoveSwitchEntry(ah:HSWITCH): Cardinal; cdecl;
  238. external 'PMSHAPI' index 129;
  239. type
  240. PSWENTRY=^SWENTRY;
  241. SWENTRY=record // swent
  242. hswitch_: HSWITCH;
  243. swctl: SWCNTRL;
  244. end;
  245. PSWBLOCK=^SWBLOCK;
  246. SWBLOCK=record // swblk
  247. cswentry: Cardinal;
  248. aswentry: Array[1..1] of SWENTRY;
  249. End;
  250. // 32-bit versions of these APIs have 32-bit parameters
  251. Function WinChangeSwitchEntry(hswitchSwitch: HSWITCH;
  252. var pswctlSwitchData: SWCNTRL): Cardinal; cdecl;
  253. external 'PMSHAPI' index 123;
  254. Function WinCreateSwitchEntry(ahab: HAB; var pswctlSwitchData: SWCNTRL): HSWITCH; cdecl;
  255. external 'PMSHAPI' index 121;
  256. Function WinQuerySessionTitle(ahab: HAB; usSession: Cardinal;
  257. var pszTitle: PAnsiChar;
  258. usTitlelen: Cardinal): Cardinal; cdecl;
  259. external 'PMSHAPI' index 122;
  260. Function WinQuerySwitchEntry(hswitchSwitch: HSWITCH;
  261. var pswctlSwitchData: SWCNTRL): Cardinal; cdecl;
  262. external 'PMSHAPI' index 124;
  263. Function WinQuerySwitchHandle(ahwnd: HWND; pidProcess: Cardinal): HSWITCH; cdecl;
  264. external 'PMSHAPI' index 125;
  265. Function WinQuerySwitchList(ahab: HAB;var pswblkSwitchEntries: SWBLOCK;
  266. usDataLength: Cardinal): Cardinal; cdecl;
  267. external 'PMSHAPI' index 126;
  268. Function WinQueryTaskSizePos(ahab: HAB; usScreenGroup: Cardinal;
  269. var pswpPositionData: SWP): Cardinal; cdecl;
  270. external 'PMSHAPI' index 127;
  271. Function WinQueryTaskTitle(usSession: Cardinal; var pszTitle: PAnsiChar;
  272. usTitlelen: Cardinal): Cardinal; cdecl;
  273. external 'PMSHAPI' index 128;
  274. Function WinSwitchToProgram(hswitchSwHandle: HSWITCH): Cardinal; cdecl;
  275. external 'PMSHAPI' index 131;
  276. // OS2.INI Access functions
  277. Function PrfQueryProfileInt(ahini: HINI; const pszApp, pszKey: PAnsiChar;
  278. sDefault: Longint): Longint; cdecl;
  279. external 'PMSHAPI' index 114;
  280. Function PrfQueryProfileString(ahini: HINI; const pszApp, pszKey, pszDefault: PAnsiChar;
  281. var pBuffer; cchBufferMax: Cardinal): Cardinal; cdecl;
  282. external 'PMSHAPI' index 115;
  283. Function PrfWriteProfileString(ahini: HINI; const pszApp, pszKey, pszData: PAnsiChar): Longbool; cdecl;
  284. external 'PMSHAPI' index 116;
  285. Function PrfQueryProfileSize(ahini: HINI; const pszApp, pszKey: PAnsiChar;
  286. var pulReqLen: Cardinal): Longbool; cdecl;
  287. external 'PMSHAPI' index 101;
  288. Function PrfQueryProfileData(ahini: HINI; const pszApp, pszKey: PAnsiChar; var pBuffer;
  289. var pulBuffLen: Cardinal): Longbool; cdecl;
  290. external 'PMSHAPI' index 117;
  291. Function PrfWriteProfileData(ahini: HINI; const pszApp, pszKey: PAnsiChar; var pData;
  292. cchDataLen: Cardinal): Longbool; cdecl;
  293. external 'PMSHAPI' index 118;
  294. Function PrfOpenProfile(ahab: HAB;const pszFileName: PAnsiChar): HINI; cdecl;
  295. external 'PMSHAPI' index 102;
  296. Function PrfCloseProfile(ahini: HINI): Longbool; cdecl;
  297. external 'PMSHAPI' index 103;
  298. Function PrfReset(ahab: HAB; var apPrfProfile: PrfProfile): Longbool; cdecl;
  299. external 'PMSHAPI' index 108;
  300. Function PrfQueryProfile(ahab: HAB; var apPrfProfile: PrfProfile): Longbool; cdecl;
  301. external 'PMSHAPI' index 107;
  302. // public message, broadcast on WinReset
  303. const
  304. PL_ALTERED=$008E; // WM_SHELLFIRST + 0E
  305. Implementation
  306. End.