home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / MFKASM.ZIP / GETHOTKY.ASM < prev    next >
Assembly Source File  |  1992-08-04  |  5KB  |  151 lines

  1. ;---------------------------------------------------------------------------;
  2. ; M.F.Kaplon  Begun:Wed  07-22-1992   Revised:Tue  08-04-1992
  3. ; Title : gethotky.asm
  4. ;
  5. ; This program will obtain current session hot keys via Keyboard IOCTL;s
  6. ; Category 4 function 76h.
  7. ;
  8. ; For System Function Calls
  9. ;
  10. ; 1 - Must use the C Calling Convention which means
  11. ;     Arguments Pushed on Stack in Reverse Order than declared in function
  12. ; 2 - Using .MODEL FLAT when using a pointer, all you have to do is push
  13. ;     the offset of the variable since in FLAT model everyting is NEAR
  14. ;     in the 32 bit space
  15. ; 3 - Uses a 16K stack
  16. ;
  17. ; cmd file to assemble and link is named mlc-w386
  18. ; and should be called as   :  mlc-w386 filename
  19. ; The cmd file assumes that "filename" is in d:\os2_asm
  20. ; Content of mlc-link386
  21. ;
  22. ; ml /c d:\os2_asm\%1.asm
  23. ; IF errorlevel 1  goto errexit
  24. ; link386 /PM:PM /ALIGN:16 /E %1.obj ;
  25. ; del *.obj
  26. ; quit
  27. ; :errexit
  28. ; Echo Compile Error NO Link
  29. ; --------------------------
  30. ;
  31. ; My source files are in D:\os2_asm and I make my calls from the C:
  32. ; root directory so that the EXE files and the OBJ file are in C:\
  33. ; and the EXE file has same name as the source file.
  34. ; If you are assembling and linking more than one then you have to
  35. ; make appropriate changes. The above does not make a map or list file
  36. ;
  37. ; I get one warning message
  38. ;
  39. ; LINK : warning L4036: no automatic data segment
  40. ;
  41. ; This message has to do with no DGROUP being defined
  42. ; It can be suppressed with DATA NONE in a "DEF" file
  43. ;
  44. ; GETHOTKY reports 3 hot keys Ctrl-Esc Alt-Esc and Alt-Home
  45. ; It does not report Alt-Tab which functions same as Alt-Esc
  46. ; Yet Alt-Tab is affected by sethotky.exe
  47. ;---------------------------------------------------------------------------;
  48. ;
  49.  
  50. .386             ;preceeding .MODEL makes USE32 default
  51. .MODEL           FLAT,SYSCALL,OS_OS2
  52. ;---------- Conditionally required equates -------------
  53. NUMBUFS             equ  1     ; Uncomment if need number routines
  54.  
  55. NOWIN               equ  1     ;Not a PM application
  56.  
  57. INCLUDE        c:\toolkt20\asm\os2inc\os2def.inc ;structure defns includes POINTL
  58. INCLUDELIB     c:\toolkt20\os2lib\os2386.lib     ;Library
  59.  
  60. INCLUDE        d:\os2_asm\equs386.inc       ;equates : MFK
  61. INCLUDE        d:\os2_asm\386_dos.mac       ;macros using DOS calls : MFK
  62.  
  63. PACKET STRUC      ; length is 6 BYTES
  64.   state     word  ?
  65.   makecode  byte  ?
  66.   breakcode byte  ?
  67.   HotKeyId  word  ?
  68. PACKET ENDS
  69.  
  70. .STACK    8096   ;8K stack
  71.  
  72. .DATA
  73.  
  74. IFDEF NUMBUFS                      ;To use  UNCOMMENT NUMBUFS equate above
  75.    $DefineNumBufs
  76. ENDIF
  77.  
  78. nwritten        DWORD  ?
  79.  
  80. ; data for DosOpen Call
  81. KBDdevice        BYTE   "KBD$",0    ; Keyboard
  82. KBDhandle        DWORD  ?         ; KBD handle returned by call
  83. KBDactcode       DWORD  ?         ; action code returned by call
  84. KBDsize          DWORD  0         ; file size for KBD
  85. KBDattr          DWORD  0         ; file attribute for KBD
  86. KBDopenflag      DWORD  1         ; open flag for KBD
  87. KBDopenmode      DWORD  0012h     ;!! 42h also OK open mode for KBD !!
  88. KBDexta          DWORD  0         ; extended attributes for KBD
  89.  
  90.  
  91. Limit            DWORD  ?         ;limit of display loop
  92. Category         DWORD  4         ;category
  93. Function         DWORD 76h        ;function - query session manager hot key
  94. DataPkt          PACKET 3 dup({?,?,?,?})
  95. ParmLnthMax      DWORD  2         ;length of ParmLIst in Bytes
  96. ParmLnthInOut    DWORD  2         ;Length in bytes of parms passed
  97. ParmList          WORD  0         ;#Get  of hot keys supported
  98. DataPktLnthMax   DWORD  6         ;data to be returned - max lenth
  99. DataPktLnthInOut DWORD  0         ;nothing passed
  100.  
  101. .CODE
  102.  
  103. startup:                         ;need to do this way with flat model
  104.  
  105. $DosWriteMsg "Getting KBD Handle from DosOpen"
  106.  
  107. $DosOpen offset KBDdevice,offset KBDhandle,offset KBDactcode,KBDsize,KBDattr,KBDopenflag,KBDopenmode,KBDexta
  108. $NewLine
  109. $DosWriteMsg "KeyBoardHandle Returned OK"      ;<nl,"Keyboard Handle Returned OK",nl>
  110.  
  111. ;------- set up for function 76h  query session manager hot key for # supported
  112.  
  113. $DosDevIOCtl KbdHandle,Category,Function,offset ParmList,ParmLnthMax,offset ParmLnthInOut,offset DataPkt, DataPktLnthMax,offset DataPktLnthInOut
  114.  
  115. $NewLine
  116. $Printf s,"Number of HotKeys Supported = ",w,ParmList
  117.  
  118. mov    ParmList,1         ;get current # of hot keys
  119. $DosDevIOCtl KbdHandle,Category,Function,offset ParmList,ParmLnthMax,offset ParmLnthInOut,offset DataPkt, DataPktLnthMax,offset DataPktLnthInOut
  120.  
  121. $NewLine
  122.  
  123. $Printf s,"Number of HotKeys Defined   = ",w,ParmList ;returns 51015
  124. $NewLine
  125.  
  126. mov    eax,6
  127. mov    ebx,0
  128. mov    bx,ParmList   ;number of entries
  129. mul    ebx             ;#entires*6
  130. dec    eax
  131. mov    Limit,eax
  132. mov    edi,0
  133. .WHILE  edi <= Limit     ; 6 is size of structure
  134.     $Printf s,"For HotKeyId = ",w,DataPkt[edi].hotkeyid,s,"  State           = ",wb,DataPkt[edi].state
  135.  
  136.     $NewLine
  137.     $Printf s,"For HotKeyId = ",w,DataPkt[edi].hotkeyid,s,"  Make Scan Code  = ",b,DataPkt[edi].Makecode
  138.  
  139.     $NewLine
  140.     $Printf s,"For HotKeyId = ",w,DataPkt.hotkeyid[edi],s,"  Break Scan Code = ",b,DataPkt[edi].Breakcode
  141.  
  142.     $NewLine
  143.     $NewLine
  144.     add    edi,6
  145. .ENDW
  146.  
  147. $DosExit
  148.  
  149. END   startup                    ;required
  150.  
  151.