home *** CD-ROM | disk | FTP | other *** search
/ PC Open 18 / pcopen18_giallo.iso / Msdos / Keybit6 / KL_API.ZIP / KL_API.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-22  |  3.6 KB  |  131 lines

  1. {************************************************************************
  2.  *                                    *
  3.  *  Unit KL_API      KEYBIT Lite API access module                *
  4.  *  Public Domain 1996 Pino Navato                    *
  5.  *                                    *
  6.  ************************************************************************}
  7.  
  8. Unit KL_API;        { ** BP 7+ required ** }
  9. {$X+}
  10.  
  11. interface
  12.  
  13. const KLACTIVE_FLAG    = 128;
  14.       EMAILSUPPORT_FLAG = 64;
  15.  
  16. function Search4Keybit : word;
  17. function GetSBptr : pointer;
  18. procedure EnableEmailSupport;
  19. procedure RestoreKeybitStatus;
  20.  
  21.  
  22. implementation
  23.  
  24. uses Strings, DOS;
  25.  
  26.  
  27. const AMIS_INSTCHECK    = 0;             { installation check }
  28.       KLAPI_GET_SB_PTR    = $10;           { get pointer to status byte }
  29.  
  30.       AMIS_SUCCESSFUL    = $FF;
  31.  
  32.  
  33. var mpx        : byte;
  34.     regs       : registers;
  35.  
  36.  
  37.  
  38. { +-----  Search4Keybit  -----------------------------------------------+
  39.   |  Purpose:    Search for KEYBIT Lite v5+ in memory.            |
  40.   |  Note:    This function sets the global variable mpx used        |
  41.   |        by GetSBptr.                        |
  42.   |  Return:    Full version number if found, 0 if not found.        |
  43.   +---------------------------------------------------------------------+ }
  44.  
  45. function Search4Keybit: word;
  46.    const KL_sig : PChar = 'Pino NavKeybit  ';    { KEYBIT's AMIS signature }
  47.    var     sig    : PChar;            { generic AMIS signature }
  48.    begin
  49.    { loop through all 256 multiplex numbers, checking signatures we find }
  50.       for mpx := 0 to 255 do
  51.      begin
  52.         regs.ah := mpx;
  53.         regs.al := AMIS_INSTCHECK;        { installation check }
  54.         intr($2D, regs);
  55.         if regs.al = AMIS_SUCCESSFUL then    { installed? }
  56.            begin
  57.           sig := ptr(regs.dx, regs.di);
  58.           if StrComp(sig, KL_sig) = 0 then   { KEYBIT Lite? }
  59.              if regs.ch >= 5 then            { v5+ ? }
  60.             begin
  61.                Search4Keybit := regs.cx; { YES! Return full v. number }
  62.                exit
  63.             end
  64.              else
  65.             break    { NO, it's an older version.  Stop searching. }
  66.            end
  67.      end;
  68.       Search4Keybit := 0
  69.    end;
  70.  
  71.  
  72.  
  73. { +-----  GetSBptr  ----------------------------------------------------+
  74.   |  Purpose:    Get a far pointer to KEYBIT Lite status byte.        |
  75.   |  Return:    Far pointer to KEYBIT Lite status byte            |
  76.   |        or nil if KEYBIT Lite v5+ not installed.        |
  77.   +---------------------------------------------------------------------+ }
  78.  
  79. function GetSBptr: pointer;
  80.    begin
  81.       if Search4Keybit = 0 then
  82.      GetSBptr := nil
  83.       else
  84.      begin
  85.         regs.ah := mpx;
  86.         regs.al := KLAPI_GET_SB_PTR;
  87.         intr($2D, regs);
  88.         GetSBptr := ptr(regs.dx, regs.bx)
  89.      end
  90.    end;
  91.  
  92.  
  93.  
  94. const status_ptr : ^byte = nil;
  95. var   old_status : byte;
  96.  
  97. { +-----  EnableEmailSupport  ------------------------------------------+
  98.   |  Purpose:    Set e-mail support flag to 1 and save original status    |
  99.   |        in the global variable old_status.            |
  100.   |  Note:    This procedure has no effect if KEYBIT Lite isn't in    |
  101.   |        memory.                            |
  102.   +---------------------------------------------------------------------+ }
  103.  
  104. procedure EnableEmailSupport;
  105.    begin
  106.       status_ptr := GetSBptr;
  107.       if status_ptr <> nil then
  108.      begin
  109.         old_status := status_ptr^;
  110.         status_ptr^ := status_ptr^ or EMAILSUPPORT_FLAG
  111.      end
  112.    end;
  113.  
  114.  
  115.  
  116. { +-----  RestoreKeybitStatus  -----------------------------------------+
  117.   |  Purpose:    Restore KEYBIT Lite's original status from the global    |
  118.   |        variable old_status.                    |
  119.   |  Note:    This procedure has no effect if KEYBIT Lite isn't in    |
  120.   |        memory or if EnableEmailSupport hasn't been called.    |
  121.   +---------------------------------------------------------------------+ }
  122.  
  123. procedure RestoreKeybitStatus;
  124.    begin
  125.       if status_ptr <> nil then
  126.      status_ptr^ := old_status
  127.    end;
  128.  
  129.  
  130. end.
  131.