home *** CD-ROM | disk | FTP | other *** search
- {$IFDEF Windows}
- !! This unit is intended for DOS apps !!
- {$ENDIF}
-
- {$IFDEF Ver55}
- !! This unit requires TP version 6 or later !!
- {$ENDIF}
-
- {*************************************************}
- {* OPWINFRN.PAS 1.00 *}
- {* Copyright TurboPower Software 1992 *}
- {*************************************************}
-
- unit OpWinFrn; {"Windows-friendly" support tools for DOS programs}
-
- interface
-
- type
- {Windows 3.x types: not installed, running Real/Std mode, running Enhanced}
- Win3ModeType = (NoWin, RealStd, Enhanced);
-
- type
- {record for DPMI version number}
- DPMIVersRec =
- record
- Major, Minor : Word;
- end;
-
- const
- {format codes for clipboard data types}
- wcb_Text = 1;
- wcb_Bitmap = 2;
- wcb_MetaFile = 3;
- wcb_SYLK = 4;
- wcb_DIF = 5;
- wcb_TIFF = 6;
-
- var
- DPMIVers : DPMIVersRec;
- WindowsMode : Win3ModeType;
-
- {Windows detection and sharing services...}
-
- function CheckWin3 : Win3ModeType;
- {-Determines whether Windows is running and, if so, what version}
- function CheckWinOldApp : Boolean;
- {-Determines whether the WINOLDAPP services are available}
- procedure GetDPMIVers;
- {-Get the version info for the current DPMI server}
- procedure ReleaseTimeSlice;
- {-Give up the current time slice; typically called in keybrd wait loops. If
- your program has sections that sit in loops performing complex processing,
- calling this service periodically will improve Windows' response to both
- it and other running programs. This is especially critical in comm program
- terminal loops and other loops that check KeyPressed each time through the
- loop.}
- procedure BeginCriticalSection;
- {-Tell Windows that your process cannot be sliced out. WARNING: Do *NOT*
- use this service unless your section *really* is critical, and then only
- for the shortest possible time!}
- procedure EndCriticalSection;
- {-Tell Windows that you are finished with the critical code section}
-
-
- {Windows clipboard data transfer tools...}
-
- function OpenClipboard : Boolean;
- {-Open clipboard; returns TRUE if clipboard available, FALSE otherwise}
- procedure CloseClipboard;
- {-Release clipboard when finished with it. Never leave the clipboard open
- longer than absolutely nessessary.}
- function ClearClipboard : Boolean;
- {-Clear the contents of the clipboard}
- function GetClipboardDataSize(Format : Word) : LongInt;
- {-Returns the number of bytes needed to hold the contents of the clipboard}
- function GetClipboardData(Format : Word; var Buffer) : Boolean;
- {-Gets the clipboard's contents. Buffer must be large enough to hold
- GetClipboardDataSize bytes.}
- function PutClipboardData(Format, BufLen : Word; var Buffer) : Boolean;
- {-Put the contents of Buffer onto the clipboard.}
-
- implementation
-
- function CheckWin3 : Win3ModeType; Assembler;
- asm
- mov ax,1600h
- int 2Fh
- cmp al,1
- jbe @@CheckRealStd
- cmp al,80h
- jae @@CheckRealStd
- mov al,2
- jmp @@ExitPoint
- @@CheckRealStd:
- mov ax,4680h
- int 2Fh
- or ax,ax
- jnz @@NotWin
- mov al,1
- jmp @@ExitPoint
- @@NotWin:
- xor al,al
- @@ExitPoint:
- end;
-
- function CheckWinOldApp : Boolean; Assembler;
- asm
- mov ax,1700h
- int 2Fh
- cmp ax,1700h
- jne @@Yes
- xor al,al
- jmp @@Done
- @@Yes:
- mov al,1
- @@Done:
- end;
-
- procedure ReleaseTimeSlice; Assembler;
- asm
- mov ax,1680h
- int 2Fh
- end;
-
- procedure BeginCriticalSection; Assembler;
- asm
- mov ax,1681h
- int 2Fh
- end;
-
- procedure EndCriticalSection; Assembler;
- asm
- mov ax,1682h
- int 2Fh
- end;
-
- function OpenClipboard : Boolean; Assembler;
- asm
- mov ax,1701h
- int 2Fh
- cmp ax,0
- je @@Done
- mov ax,1
- @@Done:
- end;
-
- procedure CloseClipboard; Assembler;
- asm
- mov ax,1708h
- int 2Fh
- xor ax,ax
- end;
-
- function ClearClipboard : Boolean; Assembler;
- asm
- mov ax,1702h
- int 2Fh
- cmp ax,0
- je @@Done
- mov ax,1
- @@Done:
- end;
-
- function GetClipboardDataSize(Format : Word) : LongInt; Assembler;
- asm
- mov ax,1704h
- mov dx,Format
- int 2Fh
- end;
-
- function GetClipboardData(Format : Word; var Buffer) : Boolean; Assembler;
- asm
- mov ax,1705h
- les di,Buffer
- mov bx,di
- mov dx,Format
- int 2Fh
- cmp ax,0
- je @@Done
- mov ax,1
- @@Done:
- end;
-
- function PutClipboardData(Format, BufLen : Word; var Buffer) : Boolean; Assembler;
- asm
- mov ax,1703h
- mov dx,Format
- les di,Buffer
- mov bx,di
- mov cx,BufLen
- xor si,si
- int 2Fh
- cmp ax,0
- je @@Done
- mov ax,1
- @@Done:
- end;
-
- function DPMIPresent : Boolean; Assembler;
- asm
- mov ax,1687h
- int 2Fh
- not ax
- end;
-
- procedure GetDPMIVers; Assembler;
- asm
- mov ax,1686h
- int 2Fh
- cmp ax,0
- jne @@Done
- mov ax,0400h
- int 31h
- mov bx,ax
- xchg bh,bl
- xor bh,bh
- xor ah,ah
- mov DPMIVers.Major,bx
- mov DPMIVers.Minor,ax
- @@Done:
- end;
-
- begin
- FillChar(DPMIVers, SizeOf(DPMIVers), 0);
- WindowsMode := CheckWin3;
- if DPMIPresent then
- GetDPMIVers;
- end.