Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. USERNAME.C
  5. Abstract:
  6. This module contains the GetUserName API.
  7. Author:
  8. Dave Snipp (DaveSn) 27-May-1992
  9. Revision History:
  10. --*/
  11. #include <advapi.h>
  12. #define SECURITY_WIN32
  13. #include <sspi.h>
  14. #include <secext.h>
  15. #include <stdlib.h>
  16. #include <ntlsa.h>
  17. //
  18. // UNICODE APIs
  19. //
  20. BOOL
  21. WINAPI
  22. GetUserNameW (
  23. LPWSTR pBuffer,
  24. LPDWORD pcbBuffer
  25. )
  26. /*++
  27. Routine Description:
  28. This returns the name of the user currently being impersonated.
  29. Arguments:
  30. pBuffer - Points to the buffer that is to receive the
  31. null-terminated character string containing the user name.
  32. pcbBuffer - Specifies the size (in characters) of the buffer.
  33. The length of the string is returned in pcbBuffer.
  34. Return Value:
  35. TRUE on success, FALSE on failure.
  36. --*/
  37. {
  38. return GetUserNameExW(
  39. NameSamCompatible | 0x00010000,
  40. pBuffer,
  41. pcbBuffer );
  42. }
  43. //
  44. // ANSI APIs
  45. //
  46. BOOL
  47. WINAPI
  48. GetUserNameA (
  49. LPSTR pBuffer,
  50. LPDWORD pcbBuffer
  51. )
  52. /*++
  53. Routine Description:
  54. This returns the name of the user currently being impersonated.
  55. Arguments:
  56. pBuffer - Points to the buffer that is to receive the
  57. null-terminated character string containing the user name.
  58. pcbBuffer - Specifies the size (in characters) of the buffer.
  59. The length of the string is returned in pcbBuffer.
  60. Return Value:
  61. TRUE on success, FALSE on failure.
  62. --*/
  63. {
  64. return GetUserNameExA(
  65. NameSamCompatible | 0x00010000,
  66. pBuffer,
  67. pcbBuffer );
  68. }