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.

87 lines
1.8 KiB

  1. #include <windows.h>
  2. #include <winioctl.h>
  3. #include <stdio.h>
  4. #include <malloc.h>
  5. #include <Shlwapi.h>
  6. #include <ntddsac.h>
  7. #include <sacapi.h>
  8. int _cdecl wmain(int argc, WCHAR **argv)
  9. {
  10. SAC_CHANNEL_OPEN_ATTRIBUTES Attributes;
  11. SAC_CHANNEL_HANDLE SacChannelHandle;
  12. int c;
  13. //
  14. // Configure the new channel
  15. //
  16. RtlZeroMemory(&Attributes, sizeof(SAC_CHANNEL_OPEN_ATTRIBUTES));
  17. Attributes.Type = ChannelTypeVTUTF8;
  18. wnsprintf(
  19. Attributes.Name,
  20. SAC_MAX_CHANNEL_NAME_LENGTH+1,
  21. L"Hello"
  22. );
  23. wnsprintf(
  24. Attributes.Description,
  25. SAC_MAX_CHANNEL_DESCRIPTION_LENGTH+1,
  26. L"Hello"
  27. );
  28. Attributes.Flags = 0;
  29. Attributes.CloseEvent = NULL;
  30. Attributes.HasNewDataEvent = NULL;
  31. //
  32. // Open the Hello channel
  33. //
  34. if (SacChannelOpen(
  35. &SacChannelHandle,
  36. &Attributes
  37. )) {
  38. printf("Successfully opened new channel\n");
  39. } else {
  40. printf("Failed to open new channel\n");
  41. goto cleanup;
  42. }
  43. //
  44. // Write to the Hello Channel
  45. //
  46. {
  47. PWCHAR String = L"Hello, World!\r\n";
  48. if (SacChannelVTUTF8WriteString(
  49. SacChannelHandle,
  50. String
  51. )) {
  52. printf("Successfully printed string to channel\n");
  53. } else {
  54. printf("Failed to print string to channel\n");
  55. }
  56. }
  57. //
  58. // Wait for user input
  59. //
  60. getc(stdin);
  61. //
  62. // Close the Hello Channel
  63. //
  64. if (SacChannelClose(&SacChannelHandle)) {
  65. printf("Successfully closed channel\n");
  66. } else {
  67. printf("Failed to close channel\n");
  68. }
  69. cleanup:
  70. return 0;
  71. }