home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
menu
/
menu1
/
origin.asm
< prev
next >
Wrap
Assembly Source File
|
1992-02-24
|
3KB
|
129 lines
; File......: ORIGIN.ASM
; Author....: Steve Larsen
; CIS ID....: 76370,1532
; Date......: $Date: 15 Aug 1991 23:08:00 $
; Revision..: $Revision: 1.1 $
; Log file..: $Logfile: E:/nanfor/src/origin.asv $
;
; This is an original work by K. Stephan Larsen and is placed in
; the public domain.
;
; Modification history:
; ---------------------
;
; $Log: E:/nanfor/src/origin.asv $
;
; REV 1.2 23 Feb 1992 A. D. McDonald
; corrected register useage error in DOS PSP get function.
; DOS returns the PSP to BX, not AX.
;
; Rev 1.1 15 Aug 1991 23:08:00 GLENN
; Forest Belt proofread/edited/cleaned up doc
;
; Rev 1.0 09 Jun 1991 00:40:16 GLENN
; Initial revision.
;
;
; $DOC$
; $FUNCNAME$
; FT_ORIGIN()
; $CATEGORY$
; Environment
; $ONELINER$
; Report the drive, path and filename of the executing program
; $SYNTAX$
; FT_ORIGIN() -> cString
; $ARGUMENTS$
; None
; $RETURNS$
; A string containing the full drive/directory/filename of
; the currently executing file.
; $DESCRIPTION$
; Often users will install multiple copies of application software,
; especially on networks and in situations where the user is trying
; to get around a copy protection scheme.
;
; This function enables you to learn the name and source location
; of the currently executing file, so that you may take whatever
; action you need to.
;
; Requires DOS v3.xx and above.
; $EXAMPLES$
; cMyFile := FT_ORIGIN()
;
; IF cMyFile <> "C:\APPDIR\MYFILE.EXE"
; ?"Incorrect startup file. Please remove/rename and start again"
; QUIT
; ENDIF
; $INCLUDE$
; $SEEALSO$
; FT_WHEREIS() FT_TREE()
; $END$
;
TITLE ORIGIN.asm
PUBLIC FT_ORIGIN
EXTRN __retc:far
_NANFOR segment word public 'CODE'
ASSUME CS:_NANFOR
FT_ORIGIN proc far
push ds ; save Clipper's environment
push es
push di
push si
push bp
mov bp, sp
mov ah, 62h ; fetch segment address of PSP
int 21h
cld
mov es, bx
mov ax, es:[2Ch] ; environment block seg is at PSP:2Ch
mov es, ax ; Env. Blk top in ES:DI, scan for 0000
xor di, di
xor ax, ax
mov cx, 0FFFFh
lf_1: repne scasb ; scan for a null terminator
mov bl, es:[di] ; found one, now check for 2 nulls in a
or bl, bl ; row, means end of env. blk.
jnz lf_1
inc di ; now test for something, if there, that's
mov ax, es:[di] ; our path.
or ax, ax
jz lf_2
inc di ; no path, point to a null
inc di
lf_2: push es ; save address of path for
push di ; return to Clipper
pop ax
pop dx
mov sp, bp ; housekeeping
pop bp
pop si
pop di
pop es
pop ds
push dx ; return path string to Clipper
push ax
call __retc
add sp,4
ret
FT_ORIGIN endp
_NANFOR ends
end