home *** CD-ROM | disk | FTP | other *** search
- program Talker;
-
- { Copyright (c) 1995 by Charles Calvert }
- { Module: Talker }
-
- { This DOS program is one half of suite of programs
- that show how a Windows program can talk to a DOS
- program. Compile this program with BP7 or other
- DOS Pascal compiler before running the Windows
- programming called TALKING. }
-
- uses
- Crt,
- Strings;
-
- function OpenClipBoard: Boolean; assembler;
- asm
- mov ax, $1701
- int $2f
- end;
-
- function ClearClipBoard: Boolean; assembler;
- asm
- mov ax, $1702
- int $2f
- end;
-
- function CloseClipBoard: Boolean; assembler;
- asm
- mov ax, $1708
- int $2f
- end;
-
- function SetClipboardData(S: String): Boolean;
- var
- S1: PChar;
- Len: Integer;
- begin
- Len := Length(S) + 1;
- GetMem(S1, Len);
- StrPCopy(S1, S);
- asm
- mov ax, $1703
- mov dx, $1
- mov si, 0
- mov cx, Len
- les bx, S1
- int $2f
- end;
- FreeMem(S1, Len);
- end;
-
- function GetClipboardDataSize: Integer; assembler;
- asm
- mov ax, $1704
- mov dx, 1
- int $2f
- end;
-
- procedure GetClipBoardData(var S: String; Size: Integer);
- var
- S1: PChar;
- begin
- GetMem(S1, Size);
- asm
- mov ax, $1705
- mov dx, 1
- les bx, S1
- int $2f
- end;
- S := StrPas(S1);
- FreeMem(S1, Size);
- end;
-
- function IsWindowsThere: Boolean; assembler;
- asm
- mov ax, $1700
- int $2f
- cmp ax, $1700
- jne @@AOK
- mov ax, 0
- @@AOK:
- end;
-
- procedure Opening;
- begin
- if not IsWindowsThere then begin
- WriteLn('Windows must be loaded to run this program!');
- Halt(1);
- end;
- end;
-
- procedure GetClipInfo;
- var
- S: String;
- begin
- OpenClipBoard;
- GetClipboardData(S, GetClipBoardDataSize);
- WriteLn('Windows says: ', S);
- CloseClipboard;
- end;
- function GetInput: Char;
- var
- Ch: Char;
- begin
- repeat
- Ch := ReadKey;
- until Ch in ['1','2'];
- GetInput := Ch;
- end;
-
- procedure ReplyToWindows;
- var
- S, S1: String;
- Ch: Char;
- begin
- OpenClipboard;
- ClearClipBoard;
- S := 'The elephant man''s giant parade!';
- S1 := 'Laughable Trees';
- WriteLn('1) ', S);
- WriteLn('2) ', S1);
- Write('Enter choice:');
- Ch := GetInput;
- if Ch = '1' then
- SetClipBoardData(S)
- else
- SetClipBoardData(S1);
- CloseClipBoard;
- end;
-
- begin
- Opening;
- GetClipInfo;
- ReplyToWindows;
- end.
-
-
-
-