cmdSend.cpp 739 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "Win32.h"
  2. #include "Function.h"
  3. #include "SharedValue.h"
  4. //Send
  5. bool SendCommand(LPCSTR command)
  6. {
  7. DWORD size = strlen(command);
  8. if (WriteFile(UIw_key, command, size, NULL, NULL) != 0)
  9. {
  10. FlushFileBuffers(UIw_key);
  11. return true;
  12. }
  13. else
  14. {
  15. Err(_T("发送命令失败\n可能是因为服务器已被关闭"));
  16. return false;
  17. }
  18. }
  19. bool SendCommand_NoErr(LPCSTR command)
  20. {
  21. DWORD size = strlen(command);
  22. if (WriteFile(UIw_key, command, size, NULL, NULL) != 0)
  23. {
  24. FlushFileBuffers(UIw_key);
  25. return true;
  26. }
  27. else
  28. {
  29. return false;
  30. }
  31. }
  32. bool SendCommand_WithID(const std::string& front, const std::string& id, const std::string& behind)
  33. {
  34. std::string temp = front + " " + id + " " + behind + "\n";
  35. return SendCommand(temp.c_str());
  36. }