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.

57 lines
1.1 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. tuser.c
  5. Abstract:
  6. This module tests windows GetUserName API.
  7. Author:
  8. Dave Snipp (DaveSn) 27-May-92
  9. Revision History:
  10. --*/
  11. #include <windows.h>
  12. #include <stdio.h>
  13. CHAR BufferA[256];
  14. WCHAR BufferW[256];
  15. DWORD cbBufA = 256, cbBufW = 256;
  16. int
  17. main (void)
  18. {
  19. if (GetUserNameW(BufferW, &cbBufW))
  20. printf("UniCode UserName : %ws\nNo of Characters = %d\n", BufferW, cbBufW);
  21. else
  22. printf("UniCode Failed : 0x%0x\n", GetLastError());
  23. if (GetUserNameA(BufferA, &cbBufA))
  24. printf("Ansi UserName : %s\nNo of Characters = %d\n", BufferA, cbBufA);
  25. else
  26. printf("Ansi Failed : 0x%0x\n", GetLastError());
  27. cbBufW=0;
  28. if (!GetUserNameW(BufferW, &cbBufW)) {
  29. printf("GetUserNameW requires %d size buffer\n", cbBufW);
  30. } else
  31. printf("GetUserNameW should not have succeeded\n");
  32. cbBufA=0;
  33. if (!GetUserNameA(BufferA, &cbBufA)) {
  34. printf("GetUserNameA requires %d size buffer\n", cbBufA);
  35. } else
  36. printf("GetUserNameA should not have succeeded\n");
  37. return(0);
  38. }