home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / WAWARE.ZIP / WINAWARE.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1991-03-22  |  4.5 KB  |  203 lines

  1. unit WinAware;
  2.  
  3. interface
  4.  
  5. Function RunningWin386(var Major, Minor : byte) : boolean;
  6. { Detects if Windows is running in 386 mode and returns major and minor
  7.   revision numbers.
  8.  
  9.   Major - Major revision number
  10.   Minor - Minor revision number
  11.   Returns true if in Windows 386 enhanced mode.
  12. }
  13.  
  14. Procedure ReleaseWinTimeSlice;
  15. { Releases the time slice for use in other tasks. }
  16.  
  17. Procedure PreventWinTaskSwitch;
  18. { Disables ability to switch between tasks. }
  19.  
  20. Procedure AllowWinTaskSwitch;
  21. { Restores ability to switch between tasks. }
  22.  
  23. Function OpenWinClip : word;
  24. { Opens the clipboard
  25.  
  26.   Returns 0 if error
  27. }
  28.  
  29. Function GetWinClipSize( FmtType : word ) : Longint;
  30. { Gets the size of data on the clipboard
  31.  
  32.   FmtType is one of :  1 : ASCII text
  33.                        2 : BitMap
  34.                        3 : MetaPictFile
  35.                        4 : SYLK
  36.                        5 : DIF
  37.                        6 : TIFF
  38.  
  39.   Returns size of data on clipboard
  40. }
  41.  
  42. Function GetWinClipData( Buffer : pointer; FmtType : word) : word;
  43. { Puts the data on the clipboard where Buffer points
  44.  
  45.   Buffer - points to a place to put the data
  46.   FmtType - code for type of data to get
  47.   Returns 0 if error
  48. }
  49.  
  50. Function PutWinClipData( Buffer : pointer;
  51.                          FmtType : word;
  52.                          Length : Longint) : word;
  53. { Puts the data where Buffer is pointing on the clipboard
  54.  
  55.   Buffer - points to the place where the data should come from
  56.   FmtType - code for type of data to get
  57.   Length - how many bytes to get
  58.   Returns 0 if error
  59.  
  60.   Make sure the data ends with a nul.
  61. }
  62.  
  63. Function ClearWinClip : word;
  64. { Clears contents of the clipboard
  65.  
  66.   Returns 0 if error
  67. }
  68.  
  69. Function CloseWinClip : word;
  70. { Closes the clipboard
  71.  
  72.   Returns 0 if error
  73. }
  74.  
  75. { NOTE: When you use the windows clipboard, use the following general
  76.         procedure:
  77.  
  78.         1. Open the clipboard
  79.         2. Get the clipboard data size
  80.         3. Create a large enough buffer
  81.         4. Call the GetWinClipData function
  82.         5. Close the Clipboard
  83.  
  84.         Don't leave the clipboard open for any longer than it takes to get
  85.         some data or to put some data because no other application can use
  86.         the clipboard until you close it.
  87. }
  88.  
  89. implementation
  90.  
  91. Function RunningWin386(var Major, Minor : byte) : boolean;
  92. var
  93.   Mjr, Mnr : byte;
  94. Begin
  95.   asm
  96.     MOV         AX, 01600H
  97.     INT         02FH
  98.     MOV         Mjr, AL
  99.     MOV         Mnr, AH
  100.   end;
  101. case Mjr of
  102.   $00, $80 : begin
  103.                RunningWin386 := false;
  104.                asm
  105.                  MOV      AX, 04680H
  106.                  INT      02FH
  107.                  MOV      Mjr, AL
  108.                  MOV      Mnr, AH
  109.                end;
  110.                if (Mjr = 0) and (Mnr = 0) then { Win 3.0 in real or std mode }
  111.                  begin
  112.                  Major := 3;
  113.                  Minor := 0;
  114.                end;
  115.              end;
  116.   $01, $FF : begin
  117.                RunningWin386 := true;
  118.                Major := 2;
  119.                Minor := Mnr;
  120.              end;
  121.   else
  122.     begin
  123.     RunningWin386 := true;
  124.     Major := Mjr;
  125.     Minor := Mnr;
  126.     end;
  127.   end;
  128. End;
  129.  
  130. Procedure ReleaseWinTimeSlice;
  131. Begin
  132.   asm
  133.     MOV     AX, 01680H
  134.     INT     02FH
  135.   end;
  136. End;
  137.  
  138. Procedure PreventWinTaskSwitch;
  139. Begin
  140.   asm
  141.     MOV     AX, 01681H
  142.     INT     02FH
  143.   end;
  144. End;
  145.  
  146. Procedure AllowWinTaskSwitch;
  147. Begin
  148.   asm
  149.     MOV     AX, 01682H
  150.     INT     02FH
  151.   end;
  152. End;
  153.  
  154. Function OpenWinClip : word; assembler;
  155.   asm
  156.     MOV     AX, 01701H
  157.     INT     02FH
  158.   end;
  159.  
  160. Function GetWinClipSize( FmtType : word ) : Longint; assembler;
  161.   asm
  162.     MOV     AX, 01704H
  163.     MOV     DX, FmtType
  164.     INT     02FH
  165.   end;
  166.  
  167. Function GetWinClipData( Buffer : pointer; FmtType : word) : word; assembler;
  168.   asm
  169.     MOV     DX, FmtType
  170.     MOV     AX, [BP + 10]
  171.     MOV     ES, AX
  172.     MOV     BX, [BP + 8]
  173.     MOV     AX, 01705H
  174.     INT     02FH
  175.   end;
  176.  
  177. Function PutWinClipData( Buffer : pointer;
  178.                          FmtType : word;
  179.                          Length : Longint) : word; assembler;
  180.   asm
  181.     MOV     DX, FmtType
  182.     MOV     AX, [BP + 14]
  183.     MOV     ES, AX
  184.     MOV     BX, [BP + 12]
  185.     MOV     SI, WORD PTR [BP + 8]
  186.     MOV     CX, WORD PTR [BP + 6]
  187.     MOV     AX, 01703H
  188.     INT     02FH
  189.   end;
  190.  
  191. Function ClearWinClip : word; assembler;
  192. asm
  193.   MOV     AX, 01702H
  194.   INT     02FH
  195. end;
  196.  
  197. Function CloseWinClip : word; assembler;
  198. asm
  199.   MOV     AX, 01708H
  200.   INT     02FH
  201. end;
  202.  
  203. END.