Jump to content

WinHAPPfromPID: Difference between revisions

From EDM2
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
WinHAPPfromPID returns the PM Application Handle ([[HAPP]]) from the process ID. If the process ID is not a valid PM application, then 0 is returned.
WinHAPPfromPID returns the PM Application Handle (HAPP) from the process ID. If the proces ID is not a valid PM application, then 0 is returned.  


==Syntax==
==Syntax==
<PRE>
  WinHAPPfromPID (PID pid)
#define INCL_PMAPI
#include os2.h>


    HAPP WinHAPPfromPID
        (PID pid)
</PRE>
==Parameters==
==Parameters==
; pid(PID) input : Process ID
;''pid'' (PID) - input : Process ID


==Return Code==
==Return Code==
happ(HAPP) returns
;happ(HAPP) returns:Application handle.
 
:; NULLHANDLE 
Application handle.
::If the PID is invalid, or an error occurred.
 
:;HAPP
* NULLHANDLE        If the PID is invalid, or an error occurred.  
::The Application Handle, if PID is valid.
* HAPP       The Application Handle, if PID is valid.


==Remarks==
==Remarks==
WinHAPPfromHSWITCH and WinHSWITCHfromHAPP may be called from non-PM programs. For some versions of OS/2 it may be necessary to import explicitly these APIs using the following ordinals
WinHAPPfromHSWITCH and [[WinHSWITCHfromHAPP]] may be called from non-PM programs. For some versions of OS/2 it may be necessary to import explicitly these APIs using the following ordinals:
 
*WinHAPPfromPID - PMMERGE.5198  
WinHAPPfromPID     PMMERGE.5198  
*[[WinHSWITCHfromHAPP]] - PMMERGE.5199
 
WinHSWITCHfromHAPP   PMMERGE.5199


==Example Code==
==Example Code==
Declaration:
<PRE>
#define INCL_PMAPI
#include  <os2.h>


    HAPP WinHAPPfromPID
</PRE>
Sample:
<PRE>
<PRE>
int main (int argc, char *argv[], char *envp[]){
int main (int argc, char *argv[], char *envp[]){
Line 50: Line 48:
   hswitch=WinHSWITCHfromHAPP(happ);    /* get HSWITCH from HAPP */
   hswitch=WinHSWITCHfromHAPP(happ);    /* get HSWITCH from HAPP */


   rc=WinQuerySwitchEntry(hswitch, swcntrl); /* interpret HSWITCH */
   rc=WinQuerySwitchEntry(hswitch, swcntrl); /* interpret HSWITCH */
   if (rc) {
   if (rc) {
     printf("WinQuerySwitchEntry returned %u\n",rc);
     printf("WinQuerySwitchEntry returned %u\n",rc);
Line 70: Line 68:
}
}
</PRE>
</PRE>


==Related Functions==
==Related Functions==
* [[OS2 API:PMI:WinHSWITCHfromHAPP|WinHSWITCHfromHAPP]]
* [[WinQuerySwitchEntry]]
* [[OS2 API:PMI:WinQuerySwitchEntry|WinQuerySwitchEntry]]
* [[WinQuerySwitchHandle]]
* [[OS2 API:PMI:WinQuerySwitchHandle|WinQuerySwitchHandle]]
* [[WinQuerySwitchList]]
* [[OS2 API:PMI:WinQuerySwitchList|WinQuerySwitchList]]
 


[[Category:The OS/2 API Project]]
[[Category:Win]]

Latest revision as of 19:28, 17 May 2025

WinHAPPfromPID returns the PM Application Handle (HAPP) from the process ID. If the process ID is not a valid PM application, then 0 is returned.

Syntax

WinHAPPfromPID (PID pid)

Parameters

pid (PID) - input
Process ID

Return Code

happ(HAPP) returns
Application handle.
NULLHANDLE
If the PID is invalid, or an error occurred.
HAPP
The Application Handle, if PID is valid.

Remarks

WinHAPPfromHSWITCH and WinHSWITCHfromHAPP may be called from non-PM programs. For some versions of OS/2 it may be necessary to import explicitly these APIs using the following ordinals:

Example Code

Declaration:

#define INCL_PMAPI
#include  <os2.h>

    HAPP WinHAPPfromPID

Sample:

int main (int argc, char *argv[], char *envp[]){

   APIRET rc;
   HAPP happ;
   HSWITCH hswitch;
   SWCNTRL swcntrl;
   PID pid;

   if (argc==1) {
     printf("QSWLIST pid\n");
     return 0;
    }   /* endif */

   pid=strtoul(argv[1],NULL,0);

   happ=WinHAPPfromPID(pid);            /* get HAPP from PID */

   hswitch=WinHSWITCHfromHAPP(happ);     /* get HSWITCH from HAPP */

   rc=WinQuerySwitchEntry(hswitch, swcntrl); /* interpret HSWITCH */
   if (rc) {
     printf("WinQuerySwitchEntry returned %u\n",rc);
     return rc;
   } /* endif */

   printf("Pid  %04x, Happ  %08x, Hswitch  %08x\n", pid, happ, hswitch);
   printf("swcntrl.hwnd      \t%08x,   swcntrl.hwndIcon     \t%08x\n",
           swcntrl.hwnd, swcntrl.hwndIcon);
   printf("swcntrl.hprog     \t%08x,   swcntrl.idProcess    \t%08x\n",
           swcntrl.hprog, swcntrl.idProcess);
   printf("swcntrl.idSession \t%08x,   swcntrl.uchVisbility \t%08x\n",
           swcntrl.idSession, swcntrl.uchVisibility);
   printf("swcntrl.fbJump    \t%08x,   swcntrl.bProgType    \t%08x\n",
           swcntrl.fbJump, swcntrl.bProgType);
   printf("swcntrl.szSwtitle %s\n",  sz.Swtitle);

   return 0;
}

Related Functions