home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / snip0693.zip / GETNAME.ASM < prev    next >
Assembly Source File  |  1992-09-03  |  3KB  |  99 lines

  1. Here you go.  Just assemble this with TASM, and link into your code.  The
  2. function USERNAME() will return the logged in name of the user.  This will
  3. work both under DOS and OS/2 requestor.  ie:
  4.  
  5. FUNCTION GetName()
  6.  
  7. winsay("The user's name is :"+username())
  8. return(username())
  9.  
  10.  
  11.  
  12. ;------------------------------------------:
  13. ; CLIPPER OBJECT file to return the USER   :
  14. ; of the logged in user                    :
  15. ;------------------------------------------:
  16.  
  17. public  UserName
  18. extrn   __retc:far
  19.  
  20. dgroup  group   datasg
  21.  
  22. datasg  segment public  '_DATA'
  23.  
  24. RequestBuffer           Label   Byte
  25. PacketLengthLow         db      2               ; request buffer 2 bytes long
  26. PacketLengthHigh        db      0
  27. Function                db      22              ; sub function to get user inf
  28. ConnectionNumber        db      ?               ; logical connection number
  29.  
  30. ReplyBuffer             Label   Byte
  31. ReturnLengthLow         db      62              ; Reply is 62 bytes long
  32. ReturnLengthHigh        db      0
  33. UniqueID                dd      ?               ; Station's ID #
  34. Typex                   dw      ?
  35. ObjectName              db      48 dup ( ? )    ; USERNAME 1-47 characters
  36. LogTime                 db      8  dup ( ? )    ; Time user logged in
  37.  
  38. datasg  ends
  39.  
  40.  
  41. _prog   segment 'CODE'
  42.         assume  CS:_prog,DS:dgroup,ES:dgroup
  43.  
  44.  
  45. UserName        proc    far
  46.  
  47.                 push    BP                      ; preserve return address
  48.                 mov     BP,SP
  49.                 push    DS
  50.                 push    ES
  51.                 push    SI
  52.                 push    DI
  53.  
  54.                 mov     AH,0DCh                 ; function to get connection #
  55.                 int     21h
  56.                 mov     ConnectionNumber,AL
  57.  
  58.  
  59.                 mov     AH,0E3h                 ; log request function #
  60.  
  61.                 mov     DX,seg dgroup:RequestBuffer
  62.                 mov     DS,DX
  63.                 mov     DX,seg dgroup:ReplyBuffer
  64.                 mov     ES,DX
  65.                 lea     SI,RequestBuffer        ;  DS:SI points to Request Buf
  66.                 lea     DI,ReplyBuffer          ;  ES:DI points to Reply Buffe
  67.  
  68.                 int     21h
  69.  
  70. ;  Return the name
  71.  
  72.                 pop     DI
  73.                 pop     SI
  74.                 pop     ES                      ; restore registers
  75.                 pop     DS
  76.                 pop     BP
  77.  
  78.                 mov     AX,seg dgroup:ObjectName
  79.                 push    AX
  80.                 mov     AX,offset dgroup:ObjectName
  81.                 push    AX
  82.                 call    __retc                  ; call character                
  83. add     SP,4                    ; fix up stack
  84.  
  85.                 ret                             ; far return
  86.  
  87. UserName        endp
  88.  
  89.  
  90. _prog           ends
  91.  
  92.                 end
  93.  
  94. ;For more CLIPPER INFORMATION, write:
  95. ;
  96. ;Staben Technologies
  97. ;811 West 14th Avenue
  98. ;Spokane, WA  99204
  99.