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.

102 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. wstsend.c
  5. Abstract:
  6. Test program for the NetMessageBufferSend APIs. Run this test after
  7. starting the Workstation service.
  8. wstsend <recipient> <message>
  9. Author:
  10. Rita Wong (ritaw) 12-Aug-1991
  11. Revision History:
  12. --*/
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <stdlib.h>
  16. #include <nt.h>
  17. #include <ntrtl.h>
  18. #include <nturtl.h>
  19. #include <winerror.h>
  20. #include <windef.h> // Win32 type definitions
  21. #include <winbase.h> // Win32 base API prototypes
  22. #include <lm.h> // LAN Man definitions
  23. #include <tstring.h>
  24. VOID
  25. main(
  26. int argc,
  27. char *argv[]
  28. )
  29. {
  30. DWORD i;
  31. NET_API_STATUS status;
  32. #ifdef UNICODE
  33. LPWSTR ToName;
  34. LPWSTR Message;
  35. #else
  36. LPSTR ToName;
  37. LPSTR Message;
  38. #endif
  39. if (argc != 3) {
  40. printf("Usage: wstsend <recipient> <message>.\n");
  41. return;
  42. }
  43. #ifdef UNICODE
  44. ToName = NetpAllocWStrFromStr(_strupr(argv[1]));
  45. if (ToName == NULL) {
  46. printf("Could not convert the receipient name.\n");
  47. return;
  48. }
  49. Message = NetpAllocWStrFromStr(argv[2]);
  50. if (ToName == NULL) {
  51. printf("Could not convert the message.\n");
  52. NetApiBufferFree(ToName);
  53. return;
  54. }
  55. #else
  56. ToName = _strupr(argv[1]);
  57. Message = argv[2];
  58. #endif
  59. if ((status = NetMessageBufferSend(
  60. NULL,
  61. ToName, // To
  62. NULL,
  63. Message, // Message to send
  64. STRLEN(Message) * sizeof(TCHAR)
  65. )) != NERR_Success) {
  66. printf("Failed in sending message to %s %lu\n", argv[1], status);
  67. printf("Message is %s\n", argv[2]);
  68. }
  69. else {
  70. printf("Message sent successfully\n");
  71. }
  72. #ifdef UNICODE
  73. NetApiBufferFree(ToName);
  74. NetApiBufferFree(Message);
  75. #endif
  76. }