home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bpos13.zip / pmshl.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-24  |  18KB  |  413 lines

  1. {*****************************************************************************\
  2. *
  3. * Module Name: PMSHL.H
  4. *
  5. * OS/2 Presentation Manager Shell constants, types, messages and
  6. * function declarations
  7. *
  8. * Copyright (c) International Business Machines Corporation 1981, 1988-1990
  9. *
  10. \*****************************************************************************}
  11. {| Version:   1.00
  12.  | Original translation: Peter Sawatzki ps
  13.  | Contributing:
  14.  |   Peter Sawatzki ps
  15.  |
  16.  | change history:
  17.  | Date:    Ver: Author:
  18.  | 11/11/93 1.00 ps     original translation by ps
  19. }
  20. Unit PmShl;
  21. Interface
  22. Uses
  23.   Os2Def,
  24.   PmWin;
  25. Const
  26. { common types, constants and function declarations             }
  27. { maximum title length }
  28.   MAXNAMEL = 60;
  29. Type
  30. { window size structure }
  31.   XYWINSIZE = Record
  32.     x,y,cx,cy: SHORT;
  33.     fsWindow: USHORT
  34.   End;
  35.   pXYWINSIZE = ^XYWINSIZE;
  36.  
  37. Const
  38. { Definitions for fsWindow }
  39.   XYF_NOAUTOCLOSE= $0008;
  40.   XYF_MINIMIZED  = $0004;                           { D23914 }
  41.   XYF_MAXIMIZED  = $0002;                           { D23914 }
  42.   XYF_INVISIBLE  = $0001;
  43.   XYF_NORMAL     = $0000;
  44.  
  45. Type
  46. { program handle }
  47.   HPROGRAM = LHANDLE;       { hprog }
  48.   pHPROGRAM = ^HPROGRAM;
  49.  
  50. { ini file handle }
  51.   HINI = LHANDLE;           { hini }
  52.   pHINI = ^HINI;
  53.  
  54. Const
  55.   HINI_PROFILE         = NULL;
  56.   HINI_USERPROFILE     = -1;
  57.   HINI_SYSTEMPROFILE   = -2;
  58.   HINI_USER    = HINI_USERPROFILE;
  59.   HINI_SYSTEM  = HINI_SYSTEMPROFILE;
  60.  
  61. Type
  62.   PRFPROFILE = Record
  63.     cchUserName: ULONG;
  64.     pszUserName: pSZ;
  65.     cchSysName: ULONG;
  66.     pszSysName: pSZ
  67.   End;
  68.   pPRFPROFILE = ^PRFPROFILE;
  69.  
  70. Const
  71. { maximum path length }
  72.   MAXPATHL = 128;
  73.  
  74. { root group handle }
  75.   SGH_ROOT      = HPROGRAM(-1);
  76.  
  77. Type
  78.   HPROGARRAY = Record
  79.     ahprog: Array[0..0] Of HPROGRAM
  80.   End;
  81.   pHPROGARRAY = ^HPROGARRAY;
  82.   PROGCATEGORY = Char;
  83.   pPROGCATEGORY = pChar;
  84.  
  85. Const
  86. { values acceptable for PROGCATEGORY for PM groups }
  87.   PROG_DEFAULT            = PROGCATEGORY(0  );
  88.   PROG_FULLSCREEN         = PROGCATEGORY(1  );
  89.   PROG_WINDOWABLEVIO      = PROGCATEGORY(2  );
  90.   PROG_PM                 = PROGCATEGORY(3  );
  91.   PROG_GROUP              = PROGCATEGORY(5  );
  92.   PROG_REAL               = PROGCATEGORY(4  );{ was 7 }
  93.   PROG_DLL                = PROGCATEGORY(6  );
  94.   PROG_RESERVED           = PROGCATEGORY(255);
  95.  
  96. { visibility flag for PROGTYPE structure }
  97.   SHE_VISIBLE   = $00;
  98.   SHE_INVISIBLE = $01;
  99.   SHE_RESERVED  = $FF;
  100.  
  101. { Protected group flag for PROGTYPE structure }
  102.   SHE_UNPROTECTED = $00;
  103.   SHE_PROTECTED   = $02;
  104.  
  105. Type
  106.   PROGTYPE = Record
  107.     progc: PROGCATEGORY;
  108.     fbVisible: UCHAR
  109.   End;
  110.   pPROGTYPE = ^PROGTYPE;
  111.  
  112.   PROGRAMENTRY = Record
  113.     hprog: HPROGRAM;
  114.     progt: PROGTYPE;
  115.     szTitle: Array[0..MAXNAMEL] Of Char
  116.   End;
  117.   pPROGRAMENTRY = ^PROGRAMENTRY;
  118.  
  119.   PIBSTRUCT = Record
  120.     progt: PROGTYPE;
  121.     szTitle: Array[0..MAXNAMEL] Of Char;
  122.     szIconFileName,
  123.     szExecutable,
  124.     szStartupDir: Array[0..MAXPATHL] Of Char;
  125.     xywinInitial: XYWINSIZE;
  126.     res1: USHORT;
  127.     res2: LHANDLE;
  128.     cchEnvironmentVars: USHORT;
  129.     pchEnvironmentVars: pCH;
  130.     cchProgramParameter: USHORT;
  131.     pchProgramParameter: pCH
  132.   End;
  133.   pPIBSTRUCT = ^PIBSTRUCT;
  134.  
  135. {****************************************************************************}
  136. {                                                                            }
  137. {  Structures associated with 'Prf' calls                                    }
  138. {                                                                            }
  139. {****************************************************************************}
  140.  
  141.   PROGDETAILS = Record
  142.     _Length: ULONG;        { set this to sizeof(PROGDETAILS)  }
  143.     progt: PROGTYPE;
  144.     pad1: Array[0..2] Of USHORT;     { ready for 32-bit PROGTYPE        }
  145.     pszTitle,              { any of the pointers can be NULL  }
  146.     pszExecutable,
  147.     pszParameters,
  148.     pszStartupDir,
  149.     pszIcon,
  150.     pszEnvironment:pSZ;        { this is terminated by  /0/0     }
  151.     swpInitial: SWP;            { this replaces XYWINSIZE         }
  152.     pad2: Array[0..4] Of USHORT;{ ready for 32-bit SWP            }
  153.   End;
  154.   pPROGDETAILS = ^PROGDETAILS;
  155.  
  156.   PROGTITLE = Record
  157.     hprog: HPROGRAM;
  158.     progt: PROGTYPE;
  159.     pad1: Array[0..2] Of USHORT; { padding ready for 32-bit PROGTYPE }
  160.     pszTitle: pSZ
  161.   End;
  162.   pPROGTITLE = ^PROGTITLE;
  163.  
  164.   QFEOUTBLK = Record
  165.     Total,
  166.     Count: USHORT;
  167.     ProgramArr: Array[0..0] Of HPROGRAM
  168.   End;
  169.   pQFEOUTBLK = ^QFEOUTBLK;
  170.  
  171. { Program List API Function Definitions }
  172. {**  Program Use }
  173. Function WinQueryProgramTitles(_hab: HAB; hprogGroup: HPROGRAM;
  174.                                aprogeBuffer: PPROGRAMENTRY; usBufferLen: USHORT; pusTotal: PUSHORT): BOOL;
  175.  
  176. {**  Single Program Manipulation }
  177. Function WinAddProgram(_hab: HAB; ppibProgramInfo: PPIBSTRUCT;
  178.                        hprogGroupHandle: HPROGRAM): HPROGRAM;
  179. Function WinQueryDefinition(_hab: HAB; hprogProgHandle: HPROGRAM;
  180.                             ppibProgramInfo: PPIBSTRUCT; usMaxLength: USHORT): USHORT;
  181.  
  182. {**  Group Manipulation }
  183. Function WinCreateGroup(_hab: HAB; pszTitle: PSZ; ucVisibility: UCHAR;
  184.                         flres1, flres2: ULONG): HPROGRAM;
  185. {****************************************************************************}
  186. {                                                                            }
  187. {  Program List API available 'Prf' calls                                    }
  188. {                                                                            }
  189. {****************************************************************************}
  190.  
  191. Function PrfQueryProgramTitles(_hini: HINI; hprogGroup: HPROGRAM;
  192.                                pTitles: PPROGTITLE; cchBufferMax: ULONG; pulCount: PULONG): ULONG;
  193.  
  194. {***************************************************************************}
  195. {                                                                           }
  196. {  NOTE: string information is concatanated after the array of PROGTITLE    }
  197. {        structures so you need to allocate storage greater than            }
  198. {        sizeof(PROGTITLE)*cPrograms to query programs in a group           }
  199. {                                                                           }
  200. {  PrfQueryProgramTitles recommended usage to obtain titles of all progams  }
  201. {  in a group (Hgroup=SGH_ROOT is for all groups):                          }
  202. {                                                                           }
  203. {  BufLen = PrfQueryProgramTitles( Hini, Hgroup                             }
  204. {                                          , (PPROGTITLE)NULL, 0, &Count);  }
  205. {                                                                           }
  206. {  Alocate buffer of  Buflen                                                }
  207. {                                                                           }
  208. {  Len = PrfQueryProgramTitles( Hini, Hgroup, (PPROGTITLE)pBuffer, BufLen   }
  209. {                                                                , pCount); }
  210. {                                                                           }
  211. {***************************************************************************}
  212.  
  213. Function PrfAddProgram (_hini: HINI; pDetails: PPROGDETAILS;
  214.                         hprogGroup: HPROGRAM): HPROGRAM;
  215. Function PrfChangeProgram (_hini: HINI; hprog: HPROGRAM; pDetails: PPROGDETAILS): BOOL;
  216.  
  217. {*************************************************************************}
  218. {  when adding/changing programs the PROGDETAILS Length field should be   }
  219. {  set to sizeof(PROGDETAILS)                                             }
  220. {*************************************************************************}
  221.  
  222. Function PrfQueryDefinition (_hini: HINI; hprog: HPROGRAM;
  223.                              pDetails: PPROGDETAILS; cchBufferMax: ULONG): ULONG;
  224.  
  225. {***************************************************************************}
  226. {                                                                           }
  227. {  NOTE: string information is concatanated after the PROGDETAILS field     }
  228. {        structure so you need to allocate storage greater than             }
  229. {        sizeof(PROGDETAILS) to query programs                              }
  230. {                                                                           }
  231. {  PrfQueryDefinition recomended usage:                                     }
  232. {                                                                           }
  233. {  bufferlen = PrfQueryDefinition( Hini, Hprog, (PPROGDETAILS)NULL, 0)      }
  234. {                                                                           }
  235. {  Alocate buffer of bufferlen bytes                                        }
  236. {  set Length field (0 will be supported)                                   }
  237. {                                                                           }
  238. {  (PPROGDETAILS)pBuffer->Length=sizeof(PPROGDETAILS)                       }
  239. {                                                                           }
  240. {  len = PrfQueryDefinition(Hini, Hprog, (PPROGDETAILS)pBuffer, bufferlen)  }
  241. {                                                                           }
  242. {***************************************************************************}
  243.  
  244. Function PrfRemoveProgram(_hini: HINI; hprog: HPROGRAM): BOOL;
  245. Function PrfQueryProgramHandle (_hini: HINI; pszExe: PSZ;
  246.                                 _phprogArray: PHPROGARRAY; cchBufferMax: ULONG; pulCount: PULONG): ULONG;
  247. Function PrfCreateGroup(_hini: HINI; pszTitle: PSZ;
  248.                         chVisibility: UCHAR): HPROGRAM;
  249. Function PrfDestroyGroup(_hini: HINI; hprogGroup: HPROGRAM): BOOL;
  250. Function PrfQueryProgramCategory(_hini: HINI; pszExe: PSZ): PROGCATEGORY;
  251.  
  252. Type
  253.   HSWITCH = LHANDLE;        { hsw }
  254.   pHSWITCH = ^HSWITCH;
  255. Const
  256. { visibility flag for SWCNTRL structure }
  257.   SWL_VISIBLE   = $04;
  258.   SWL_INVISIBLE = $01;
  259.   SWL_GRAYED    = $02;
  260.  
  261. { visibility flag for SWCNTRL structure }
  262.   SWL_JUMPABLE    = $02;
  263.   SWL_NOTJUMPABLE = $01;
  264. Type
  265.   SWCNTRL = Record
  266.     hwnd,
  267.     hwndIcon: HWND;
  268.     hprog: HPROGRAM;
  269.     idProcess,
  270.     idSession: USHORT;
  271.     uchVisibility,
  272.     fbJump: UCHAR;
  273.     szSwtitle: Array[0..MAXNAMEL] Of Char;
  274.     fReserved: BYTE        { To align on word boundary }
  275.   End;
  276.   pSWCNTRL = ^SWCNTRL;
  277.  
  278. {** Switching Program functions }
  279. {E}Function WinAddSwitchEntry(_PSWCNTRL: PSWCNTRL): HSWITCH;
  280. {E}Function WinRemoveSwitchEntry(_HSWITCH: HSWITCH): USHORT;
  281.  
  282. Type
  283.   SWENTRY = Record
  284.     _hswitch: HSWITCH;
  285.     swctl: SWCNTRL
  286.   End;
  287.   pSWENTRY = ^SWENTRY;
  288.  
  289.   SWBLOCK = Record
  290.     cswentry: USHORT;
  291.     aswentry: Array[0..0] Of SWENTRY
  292.   End;
  293.   pSWBLOCK = ^SWBLOCK;
  294.  
  295. Function WinChangeSwitchEntry(hswitchSwitch: HSWITCH;
  296.                                  pswctlSwitchData: PSWCNTRL): USHORT;
  297. Function WinCreateSwitchEntry(_HAB: HAB; _PSWCNTRL: PSWCNTRL): HSWITCH;
  298. Function WinQuerySessionTitle(_hab: HAB; usSession: USHORT;
  299.                                  pszTitle: PSZ; usTitlelen: USHORT): USHORT;
  300. Function WinQuerySwitchEntry(hswitchSwitch: HSWITCH; pswctlSwitchData: PSWCNTRL): USHORT;
  301. Function WinQuerySwitchHandle(_hwnd: HWND; usProcess: PID): HSWITCH;
  302. Function WinQuerySwitchList(_hab: HAB; pswblkSwitchEntries: PSWBLOCK;
  303.                                usDataLength: USHORT): USHORT;
  304. Function WinQueryTaskSizePos(_hab: HAB; usScreenGroup: USHORT;
  305.                                 pswpPositionData: PSWP): USHORT;
  306. Function WinQueryTaskTitle(usSession: USHORT; pszTitle: PSZ;
  307.                               usTitlelen: USHORT): USHORT;
  308. Function WinSwitchToProgram(hswitchSwHandle: HSWITCH): USHORT;
  309.  
  310. { if error definitions are required then allow Shell errors }
  311.  
  312. {** OS2.INI Access functions }
  313. Function WinQueryProfileInt(hab: HAB; pszAppName: PSZ; pszKeyName: PSZ;
  314.                             sDefault: SHORT): SHORT;
  315. Function WinQueryProfileString(hab: HAB; pszAppName, pszKeyName: PSZ;
  316.                                pszDefault: PSZ; pProfileString: PVOID; usMaxPstring: USHORT): USHORT;
  317. Function WinWriteProfileString(hab: HAB; pszAppName, pszKeyName: PSZ;
  318.                                pszValue: PSZ): BOOL;
  319. Function WinQueryProfileSize(hab: HAB; pszAppName, pszKeyName: PSZ;
  320.                              pusValue: PUSHORT): USHORT;
  321. Function WinQueryProfileData(hab: HAB; pszAppName, pszKeyName: PSZ;
  322.                              pValue: PVOID; pusSize: PUSHORT): BOOL;
  323. Function WinWriteProfileData(hab: HAB; pszAppName, pszKeyName: PSZ;
  324.                              pValue: PVOID; usSize: USHORT): BOOL;
  325.  
  326. {****************************************************************************}
  327. {                                                                            }
  328. {  INI file access API available calls 'Prf'                                 }
  329. {                                                                            }
  330. {****************************************************************************}
  331.  
  332. Function PrfQueryProfileInt(hini: HINI; pszApp, pszKey: PSZ;
  333.                             sDefault: SHORT): SHORT;
  334. Function PrfQueryProfileString(hini: HINI; pszApp, pszKey: PSZ;
  335.                                pszDefault: PSZ; pBuffer: PVOID; cchBufferMax: ULONG): ULONG;
  336. Function PrfWriteProfileString(hini: HINI; pszApp, pszKey, pszData: PSZ): BOOL;
  337. Function PrfQueryProfileSize(hini: HINI; pszApp, pszKey: PSZ; pulReqLen: PULONG): BOOL;
  338. Function PrfQueryProfileData(hini: HINI; pszApp, pszKey: PSZ;
  339.                              pBuffer: PVOID; pulBuffLen: PULONG): BOOL;
  340. Function PrfWriteProfileData(hini: HINI; pszApp, pszKey: PSZ;
  341.                              pData: PVOID; cchDataLen: ULONG): BOOL;
  342. Function PrfOpenProfile(hab: HAB; pszFileName: PSZ): HINI;
  343. Function PrfCloseProfile(hini: HINI): BOOL;
  344. Function PrfReset(hab: HAB; pPrfProfile: PPRFPROFILE): BOOL;
  345. Function PrfQueryProfile(hab: HAB; pPrfProfile: PPRFPROFILE): BOOL;
  346.  
  347. Const
  348. { new public message, broadcast on WinReset }
  349.   PL_ALTERED = $008E;  { WM_SHELLFIRST + 0E }
  350.  
  351. Type
  352.   HAPP = LHANDLE;
  353.   ppSZ = ^pSZ;
  354.  
  355.   Function WinInstStartApp (hini: HINI;hwndNotifyWindow: HWND;cCount: USHORT;Var aszApplication: PSZ;
  356.                             pszCmdLine: PSZ;pData: PVOID;fsOptions: USHORT): HAPP;
  357.  
  358.   Function WinTerminateApp (happ: HAPP): BOOL;
  359.  
  360. Const
  361. { bit values for Options parameter of WinInstStartAppl }
  362.   SAF_VALIDFLAGS = $001F;
  363.   SAF_INSTALLEDCMDLINE= $0001; { use installed parameters }
  364.   SAF_STARTCHILDAPP= $0002; { related application      }
  365.   SAF_MAXIMIZED = $0004;  { Start App maximized }
  366.   SAF_MINIMIZED = $0008;  { Start App minimized, if !SAF_MAXIMIZED }
  367.   SAF_BACKGROUND= $0010;  { Start app in the background }
  368.  
  369. Implementation
  370.   Function PrfAddProgram;                 External 'PMSHAPI'  Index   50;
  371.   Function PrfChangeProgram;              External 'PMSHAPI'  Index   52;
  372.   Function PrfCloseProfile;               External 'PMSHAPI'  Index   39;
  373.   Function PrfCreateGroup;                External 'PMSHAPI'  Index   55;
  374.   Function PrfDestroyGroup;               External 'PMSHAPI'  Index   60;
  375.   Function PrfOpenProfile;                External 'PMSHAPI'  Index   38;
  376.   Function PrfQueryDefinition;            External 'PMSHAPI'  Index   53;
  377.   Function PrfQueryProfile;               External 'PMSHAPI'  Index   43;
  378.   Function PrfQueryProfileData;           External 'PMSHAPI'  Index   36;
  379.   Function PrfQueryProfileInt;            External 'PMSHAPI'  Index   32;
  380.   Function PrfQueryProfileSize;           External 'PMSHAPI'  Index   35;
  381.   Function PrfQueryProfileString;         External 'PMSHAPI'  Index   33;
  382.   Function PrfQueryProgramCategory;       External 'PMSHAPI'  Index   59;
  383.   Function PrfQueryProgramHandle;         External 'PMSHAPI'  Index   58;
  384.   Function PrfQueryProgramTitles;         External 'PMSHAPI'  Index   54;
  385.   Function PrfRemoveProgram;              External 'PMSHAPI'  Index   51;
  386.   Function PrfReset;                      External 'PMSHAPI'  Index   42;
  387.   Function PrfWriteProfileData;           External 'PMSHAPI'  Index   37;
  388.   Function PrfWriteProfileString;         External 'PMSHAPI'  Index   34;
  389.   Function WinAddProgram;                 External 'PMSHAPI'  Index   12;
  390.   Function WinAddSwitchEntry;             External 'OS2SM'    Index    9;
  391.   Function WinChangeSwitchEntry;          External 'OS2SM'    Index   10;
  392.   Function WinCreateGroup;                External 'PMSHAPI'  Index   17;
  393.   Function WinCreateSwitchEntry;          External 'OS2SM'    Index    7;
  394.   Function WinInstStartApp;               External 'OS2SM'    Index    5;
  395.   Function WinQueryDefinition;            External 'PMSHAPI'  Index   15;
  396.   Function WinQueryProfileData;           External 'PMSHAPI'  Index    6;
  397.   Function WinQueryProfileInt;            External 'PMSHAPI'  Index    2;
  398.   Function WinQueryProfileSize;           External 'PMSHAPI'  Index    5;
  399.   Function WinQueryProfileString;         External 'PMSHAPI'  Index    3;
  400.   Function WinQueryProgramTitles;         External 'PMSHAPI'  Index   16;
  401.   Function WinQuerySessionTitle;          External 'OS2SM'    Index    8;
  402.   Function WinQuerySwitchEntry;           External 'OS2SM'    Index   11;
  403.   Function WinQuerySwitchHandle;          External 'OS2SM'    Index   12;
  404.   Function WinQuerySwitchList;            External 'OS2SM'    Index   15;
  405.   Function WinQueryTaskSizePos;           External 'OS2SM'    Index   14;
  406.   Function WinQueryTaskTitle;             External 'OS2SM'    Index   13;
  407.   Function WinRemoveSwitchEntry;          External 'OS2SM'    Index   16;
  408.   Function WinSwitchToProgram;            External 'OS2SM'    Index   17;
  409.   Function WinTerminateApp;               External 'OS2SM'    Index    6;
  410.   Function WinWriteProfileData;           External 'PMSHAPI'  Index    7;
  411.   Function WinWriteProfileString;         External 'PMSHAPI'  Index    4;
  412. End.
  413.