SHARE
TWEET

Untitled

a guest May 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2.  
  3. #include <iostream>
  4.  
  5. int main()
  6.  
  7. {
  8.  
  9.     HANDLE hslot;
  10.  
  11.     LPCTSTR slotname = TEXT("\\\\.\\mailslot\\demoslot");
  12.  
  13.     hslot = CreateFile(slotname, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
  14.  
  15.     if (hslot == INVALID_HANDLE_VALUE)
  16.  
  17.     {
  18.  
  19.         std::cout << "SLOT WRITING FAILED" << std::endl;
  20.  
  21.         std::cout << "PRESS KEY TO FINICH" << std::endl;
  22.  
  23.         std::cin.get();
  24.  
  25.         return 0;
  26.  
  27.     }
  28.  
  29.     std::cout << "SLOT IS WAITING" << std::endl;
  30.  
  31.     int nData;
  32.  
  33.     char n[16] = "some string";
  34.  
  35.     DWORD dwBytesWrite;
  36.  
  37.     if (!WriteFile(hslot, &n, sizeof(n), &dwBytesWrite, NULL))
  38.  
  39.     {
  40.  
  41.         std::cout << "WRITE FAILED" << std::endl;
  42.  
  43.         CloseHandle(hslot);
  44.  
  45.         std::cout << "PRESS KEY TO FINICH" << std::endl;
  46.  
  47.         std::cin.get();
  48.  
  49.         return 0;
  50.  
  51.     }
  52.  
  53.     std::cout << "Data WRITTEN TO BOX: \n" << n << std::endl;
  54.  
  55.     std::cout << "PRESS KEY TO FINICH" << std::endl;
  56.  
  57.     CloseHandle(hslot);
  58.  
  59.     std::cin.get();
  60.  
  61.     return 0;
  62.  
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top