Windows NT 4.0 source code leak
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.

70 lines
1.4 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. tmscli.c
  5. Abstract:
  6. Test program to Win32 mailslot API calls
  7. Author:
  8. Manny Weiser (mannyw) 5-May-1991
  9. Revision History:
  10. --*/
  11. #include "stdio.h"
  12. #include "windows.h"
  13. char Buffer[] = "This is a message";
  14. DWORD
  15. main(
  16. int argc,
  17. char *argv[],
  18. char *envp[]
  19. )
  20. {
  21. BOOL success;
  22. HANDLE handle;
  23. LPSTR mailslotName = "\\\\.\\mailslot\\asdf";
  24. DWORD bytesWritten;
  25. handle = CreateFile( mailslotName,
  26. GENERIC_WRITE,
  27. FILE_SHARE_WRITE | FILE_SHARE_READ,
  28. NULL,
  29. OPEN_EXISTING,
  30. FILE_ATTRIBUTE_NORMAL,
  31. 0 );
  32. if (handle == (HANDLE)-1) {
  33. printf ("Failed to open mailslot ""%s""\n", mailslotName);
  34. printf ("Error = %lx\n", GetLastError() );
  35. return 1;
  36. }
  37. printf ("Successfully opened the mailslot.\n");
  38. success = WriteFile( handle,
  39. Buffer,
  40. sizeof(Buffer),
  41. &bytesWritten,
  42. NULL );
  43. if (!success) {
  44. printf ("Failed to read mailslot\n");
  45. return 1;
  46. } else {
  47. printf ("Successfully wrote %d bytes '%s'\n", bytesWritten, Buffer );
  48. }
  49. }