home *** CD-ROM | disk | FTP | other *** search
- {$B-,D-,F-,I+,N-,R-,S+,V+}
-
- (*
- Timo Salmi UNiT I
- A Turbo Pascal unit for putting infomation into the program's .exe file
- and retrieving .exe file information
- All rights reserved 1-Aug-90
- Updated 8-Aug-90
-
- This unit may be used and distributed freely for PRIVATE, NON-COMMERCIAL,
- NON-INSTITUTIONAL purposes, provided it is not changed in any way. For
- ANY other usage, such as use in a business enterprise or a university,
- contact the author for the terms of registration.
-
- The units are under development. Comments and contacts are solicited. If
- you have any questions, please do not hesitate to use electronic mail for
- communication.
- InterNet address: ts@chyde.uwasa.fi (preferred)
- Funet address: GADO::SALMI
- Bitnet address: SALMI@FINFUN
-
- The author shall not be liable to the user for any direct, indirect or
- consequential loss arising from the use of, or inability to use, any unit,
- program or file howsoever caused. No warranty is given that the units and
- programs will work under all circumstances.
-
- Timo Salmi
- Professor of Accounting and Business Finance
- School of Business Studies, University of Vaasa
- P.O. BOX 297, SF-65101 Vaasa, Finland
- *)
-
- unit TSUNTI;
-
- (* ======================================================================= *)
- interface
- (* ======================================================================= *)
-
- uses Dos
- {$IFDEF VER40} (* To provide what TP 4.0 is missing *)
- ,TSUNT45 (* as compared to TP 5.0 and TP 5.5 *)
- {$ENDIF}
- ;
-
- (* ====================================================================
- Write / read the .exe file
- ==================================================================== *)
-
- (* This procedure returns the number of times the program has been called.
- It also returns an error status string. In case of success the status
- string is empty, that is ''. The procedure works by saving the count
- into your compiled .exe file. The counter is initialized to 0 every
- time when you (re)compile your program. Note that after calling USECOUNT
- {$I+} will have been turned on. Making the .exe file readonly will
- invoke an error status. *)
- procedure USECOUNT (var TimesCalled : longint;
- var status : string);
-
- (* Here is a faster and more general alternative to USECOUNT. This one is,
- however, much more difficult to use since you have to provide it the
- necessary information all youself. Study the example test in TSUNTI.TST
- carefully and experiment to get the hang of it. Does not work for
- MsDos versions earlier than 3. For earlier versions does nothing.
- Be very careful to give the correct size of your variable (SizeOfVariable)
- to the routine. Record variables are allowed, so you can pass on large
- amounts of information in the .exe. *)
- procedure BRANDEXE
- (var Variable; (* any type of variable information *)
- SizeOfVariable : word; (* give the size of your variable *)
- var status : word); (* returns 0 if successfull *)
-
- (* This function calculates the direct chekcsum of your program's .exe
- file when you include this function in your program. The trick is
- that the var Variable (which can be of any type) is not included
- in the checksum. Thus the Variable can contain any prerecorded
- information such as what the checksum should be. Be very careful to
- give the correct size of your variable (SizeOfVariable) to the routine.
- Record variables are allowed. The function requires at least Dos version
- 3.0, TP version 5.0 or 5.5, and a heap of about 12000 bytes. If the
- checksum calculation cannot be performed fails, chksumfn returns 0.
-
- Study TSUNTI.TST TEST4 carefully for the correct usage
-
- *)
- function CHKSUMFN
- (var Variable; (* any type of variable information *)
- SizeOfVariable : word) (* give the size of your variable *)
- : longint;
-