| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "Win32.h"
- #include "ID.h"
- #include "Function.h"
- static void AutoClose(DWORD time, LPCWSTR title)
- {
- Sleep(time*1000);
- HWND box = FindWindow(NULL, title);
- if (box)
- {
- SendMessage(box, WM_CLOSE, 0, 0);
- }
- }
- //Open&Stop
- PROCESS_INFORMATION pi;
- HWND hBDS;
- static void CloseHandleA()
- {
- CloseHandle(BDSr_key);
- CloseHandle(UIw_key);
- CloseHandle(UIr_log);
- CloseHandle(BDSw_log);
- }
- static void CloseHandleS()
- {
- CloseHandle(BDSr_key);
- CloseHandle(BDSw_log);
- }
- InitH(BDSr_key); InitH(UIw_key); InitH(BDSw_log); InitH(UIr_log);
- void StartBDS()
- {
- SECURITY_ATTRIBUTES sa = { sizeof(sa), NULL, TRUE };
- if(!CreatePipe(&BDSr_key, &UIw_key, &sa, 0))
- Err(_T("Failed to create pipe_key"));
- if (!CreatePipe(&UIr_log, &BDSw_log, &sa, 0))
- Err(_T("Failed to create pipe_log"));
- STARTUPINFO si = { sizeof(si) };
- si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
- si.hStdInput = BDSr_key;
- si.hStdOutput = BDSw_log;
- si.wShowWindow = SW_SHOWMINIMIZED;
- if (CreateProcess(
- L"bedrock_server.exe",
- NULL, NULL, NULL, TRUE, NULL, NULL, NULL, &si, &pi))
- {
- CloseHandleS();
- }
- else {
- Err(_T("Failed to send command to BDS!"));
- CloseHandleA();
- }
- }
- void StopBDS()
- {
- if (pi.hProcess)
- {
- SendCommand(C("stop"));
- CloseHandleA();
- }
- }
- void ForceStopBDS()
- {
- if(pi.hProcess)
- {
- TerminateProcess(pi.hProcess, 0);
- CloseHandleA();
- MessageBox(hWnd,
- _T("Òѳ¢ÊÔÇ¿ÐÐÍ£Ö¹·þÎñÆ÷"), TITLE,
- MB_OK);
- }
- }
|