From 861a04e7a0a812acde3c0f1e19edfd0b9e8ec8dc Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Tue, 21 Feb 2023 16:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=8D=B8=E8=BD=BDdll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.cc | 2 +- src/common.cc | 7 +++++++ src/common.h | 1 + src/dllMain.cc | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api.cc b/src/api.cc index 602524c..9c0a171 100644 --- a/src/api.cc +++ b/src/api.cc @@ -701,7 +701,7 @@ int http_start(int port) { #endif kHttpRuning = true; kHttpThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)http_server, - (LPVOID)port, NULL, 0); + (LPVOID)port, NULL, 0); return 0; } diff --git a/src/common.cc b/src/common.cc index 6d1288d..e60a3a1 100644 --- a/src/common.cc +++ b/src/common.cc @@ -135,4 +135,11 @@ BOOL FindOrCreateDirectoryW(const wchar_t *path) { return false; } return true; +} + +void CloseConsole(){ + fclose(stdin); + fclose(stdout); + fclose(stderr); + FreeConsole(); } \ No newline at end of file diff --git a/src/common.h b/src/common.h index f9eb55f..229b0fa 100644 --- a/src/common.h +++ b/src/common.h @@ -53,6 +53,7 @@ std::string Wstring2String(std::wstring wstr); /// @return BOOL FindOrCreateDirectoryW(const wchar_t *path); +void CloseConsole(); template std::vector split(T1 str, T2 letter) { diff --git a/src/dllMain.cc b/src/dllMain.cc index 355e03d..40a1cef 100644 --- a/src/dllMain.cc +++ b/src/dllMain.cc @@ -16,6 +16,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, break; } case DLL_PROCESS_DETACH: { + CloseConsole(); http_close(); break; }