home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 8 / 08.iso / d / d026 / 25.ddi / NET / WNETUSER.AS_ / WNETUSER.AS
Encoding:
Text File  |  1991-04-19  |  4.8 KB  |  150 lines

  1. page        60, 132
  2. title        Windows Network User Logon / Logoff Functions
  3. ;===============================================================================
  4. ;        Filename    WNETUSER.ASM
  5. ;        Copyright    (C) 1989 by Research Machines
  6. ;        Copyright    (C) 1989-1990 by Microsoft Corporation
  7. ;===============================================================================
  8. ; REVISIONS:    24/02/1989    Initial version
  9. ;        23/03/1989    Change to segment name / file name
  10. ;        23/03/1989    Update to spec 0.58
  11. ;        31/03/1989    Tidied up comments
  12. ;===============================================================================
  13.  
  14.         memM    equ    1        ; Middle memory model
  15.         ?WIN    =    1        ; Windows prolog/epilog
  16.         ?PLM    =    1        ; Pascal calling convention
  17.  
  18.         .xlist
  19. include     cmacros.inc
  20. include     windows.inc
  21. include     wnet.inc
  22. include     wnetcaps.inc
  23.         .list
  24.  
  25.         .sall
  26.  
  27. externFP    UTLRemoveTrailingSpaces             ; In file UTILS.ASM
  28. externFP    MSNetGetMachineName                ; In file MSNET.ASM
  29.  
  30. externFP    lstrlen             ; in KERNEL
  31. externFP    lstrcpy             ; in KERNEL
  32.  
  33. ;===============================================================================
  34. ; ============= DATA SEGMENT ===================================================
  35. ;===============================================================================
  36.  
  37. sBegin        DATA
  38.  
  39. sEnd        DATA
  40.  
  41. ;===============================================================================
  42. ; ============= CODE SEGMENT ===================================================
  43. ;===============================================================================
  44.  
  45. sBegin        CODE
  46.         assumes CS, CODE
  47.         assumes DS, DATA
  48.  
  49. ;===============================================================================
  50. ; ============= EXPORTED FUNTIONS ==============================================
  51. ;===============================================================================
  52.  
  53. ;===============================================================================
  54. subttl        WNetGetUser
  55. page
  56. ;===============================================================================
  57. ;
  58. ; DESCRIPTION . Return the current user name.
  59. ;        This is the same as the machine name.
  60. ; ENTRY ....... lpszUser points to the user supplied buffer.
  61. ;        lpnBufferSize points to a word holding the size of szUser.
  62. ; EXIT ........ AX hold WN_SUCCESS or not.
  63. ;        If success, szUser is filled with the current user name.
  64. ;        nBufferSize is set to the length of the current user name.
  65. ; COMMENT ..... Uses DosGetMachineName (5e00h)
  66. ;
  67. ;===============================================================================
  68.  
  69. cProc        WNetGetUser, <FAR, PUBLIC>, <si>
  70.  
  71.         parmD    lpszUser                ; Pointer to buffer
  72.         parmD    lpnBufferSize                ; Size of buffer
  73.  
  74.         localW    nReturnCode                ; Return code
  75.         localV    szT, 16
  76. cBegin
  77.  
  78. ;---------------------------------------------------------------
  79. ; Get the machine name
  80. ;---------------------------------------------------------------
  81.  
  82. WNGUGetName:    push    ss
  83.         lea    si,szT
  84.         push    si
  85.         cCall    MSNetGetMachineName            ;
  86.  
  87.         cmp    ax, WN_SUCCESS                ; Successful?
  88.         je    TidyUserName                ; Yes!
  89.  
  90.         mov    ax, WN_NET_ERROR            ; Set return code
  91.         jmp    short WNGUExit                ; Exit
  92. TidyUserName:
  93.  
  94. ifdef NO_DO_THIS_KEMOSABE
  95. ;---------------------------------------------------------------
  96. ; Remove trailing spaces from the user name
  97. ;---------------------------------------------------------------
  98.  
  99.         Arg    RegPairSSSI
  100.         cCall    lstrlen                 ; get length of username
  101.  
  102.         Arg    RegPairSSSI                ; Remove trailing spaces
  103.         Arg    ax                    ;
  104.         cCall    UTLRemoveTrailingSpaces         ;
  105. endif
  106.  
  107. ;---------------------------------------------------------------
  108. ; Check if the users buffer is large enough to hold the name.
  109. ; Update nBufferSize to actual.
  110. ;---------------------------------------------------------------
  111.  
  112.         push    ss
  113.         lea    ax, szT
  114.         push    ax
  115.         cCall    lstrlen                 ;
  116.         inc    ax                    ; Plus terminating NULL
  117.  
  118.         les    bx, ( lpnBufferSize )            ; Pointer to buffer size
  119.         xchg    ax, es: [ bx ]                ; Update to size required
  120.         cmp    ax, es: [ bx ]                ; Large enough?
  121.         jae    CopyUserName                ; Yes!
  122.  
  123.         mov    ax, WN_MORE_DATA            ; Name will not fit
  124.         jmp    short WNGUExit
  125.  
  126. ;---------------------------------------------------------------
  127. ; Copy the machine name to the user supplied buffer
  128. ;---------------------------------------------------------------
  129.  
  130. CopyUserName:    Arg    lpszUser                ; -> user buffer
  131.         Arg    RegPairSSSI                ; -> machine name
  132.         cCall    lstrcpy                 ; Move those bytes
  133.  
  134.         mov    ax,WN_SUCCESS
  135.  
  136. ;---------------------------------------------------------------
  137. ; Return to the caller
  138. ;---------------------------------------------------------------
  139.  
  140. WNGUExit:
  141.  
  142. cEnd
  143.  
  144. ;===============================================================================
  145. ; ============= END OF WNETUSER ================================================
  146. ;===============================================================================
  147.  
  148. sEnd        CODE
  149.         end
  150.