pmshl.pas 12 KB

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