Leaked source code of windows server 2003
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.

59 lines
1.5 KiB

  1. #include <windows.h>
  2. #include <winioctl.h>
  3. #include <stdio.h>
  4. #include <malloc.h>
  5. void NewLine(void);
  6. void ScrollScreenBuffer(HANDLE, INT);
  7. #define MyErrorExit
  8. HANDLE _ScreenHandle;
  9. CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
  10. void __cdecl wmain(void)
  11. {
  12. COORD CursorPosition;
  13. WCHAR chBuffer[256];
  14. DWORD cRead, cWritten, fdwMode, fdwOldMode;
  15. WORD wOldColorAttrs;
  16. ULONG i;
  17. HANDLE _ScreenHandle;
  18. // Get handles to STDIN and STDOUT.
  19. _ScreenHandle = CreateFile( (LPWSTR)L"CONOUT$",
  20. GENERIC_READ | GENERIC_WRITE,
  21. 0,
  22. NULL,
  23. OPEN_EXISTING,
  24. 0,
  25. NULL );
  26. #if 0
  27. CursorPosition.Y = 24;
  28. CursorPosition.X = 1;
  29. SetConsoleCursorPosition( _ScreenHandle, CursorPosition );
  30. #endif
  31. while (1)
  32. {
  33. for (i = 0; i < 100; i++) {
  34. wsprintf(chBuffer, L"%d percent completed, bob. \r", i);
  35. if (! WriteConsole(
  36. _ScreenHandle, // output handle
  37. chBuffer, // prompt string
  38. wcslen(chBuffer), // string length
  39. &cWritten, // bytes written
  40. NULL) ) // not overlapped
  41. {
  42. break;
  43. }
  44. }
  45. }
  46. }