diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d360d..524b464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,4 +36,4 @@ add_subdirectory(GUI) add_subdirectory(GUI/host) add_subdirectory(texthook) add_subdirectory(extensions) -add_subdirectory(testbed) +add_subdirectory(test) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 8eafe37..2d9c70c 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -15,8 +15,6 @@ add_library(Remove\ Repetition MODULE removerepeat.cpp extensionimpl.cpp) add_library(Replacer MODULE replacer.cpp extensionimpl.cpp) add_library(Thread\ Linker MODULE threadlinker.cpp extensionimpl.cpp) -add_executable(Extension_Tests extensiontester.cpp) - target_link_libraries(Bing\ Translate winhttp Qt5::Widgets) target_link_libraries(Extra\ Window Qt5::Widgets) target_link_libraries(Google\ Translate winhttp Qt5::Widgets) diff --git a/extensions/extensiontester.cpp b/extensions/extensiontester.cpp deleted file mode 100644 index e34841a..0000000 --- a/extensions/extensiontester.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "common.h" -#include - -int main() -{ - wchar_t path[MAX_PATH] = {}; - GetModuleFileNameW(NULL, path, MAX_PATH); - *(wcsrchr(path, L'\\') + 1) = 0; - for (auto file : std::filesystem::directory_iterator(path)) - if (file.path().extension() == L".dll") LoadLibraryW(file.path().c_str()); - Sleep(10000); -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..0cd93f8 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(Test WIN32 main.cpp resource.rc) diff --git a/testbed/main.cpp b/test/main.cpp similarity index 57% rename from testbed/main.cpp rename to test/main.cpp index dabe57e..66b88a9 100644 --- a/testbed/main.cpp +++ b/test/main.cpp @@ -1,13 +1,19 @@ #include "common.h" #include "defs.h" #include "resource.h" +#include +#include +#include wchar_t buffer[1000] = {}; std::array vars = {}; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { - LoadLibraryW(ITH_DLL); + for (auto file : std::filesystem::directory_iterator(std::filesystem::current_path())) + if (file.path().extension() == L".dll" + && (std::stringstream() << std::ifstream(file.path(), std::ios::binary).rdbuf()).str().find("OnNewSentence") != std::string::npos) + LoadLibraryW(file.path().c_str()); ShowWindow(CreateDialogParamW(hInstance, MAKEINTRESOURCEW(IDD_DIALOG1), NULL, [](HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> INT_PTR { @@ -37,7 +43,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) return FALSE; }, 0), SW_SHOW); - std::thread([] { while (true) lstrlenW(L"こんにちは"); }).detach(); + std::thread([] { while (true) Sleep(vars.at(0)), lstrlenW(L"こんにちは"); }).detach(); + + STARTUPINFOW info = { sizeof(info) }; + wchar_t commandLine[] = { L"Textractor -p\"Test.exe\"" }; + CreateProcessW(NULL, commandLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &info, DUMMY); MSG msg; while (GetMessageW(&msg, NULL, 0, 0) > 0) diff --git a/testbed/resource.h b/test/resource.h similarity index 100% rename from testbed/resource.h rename to test/resource.h diff --git a/testbed/resource.rc b/test/resource.rc similarity index 90% rename from testbed/resource.rc rename to test/resource.rc index 64dd59d..0baf4fb 100644 Binary files a/testbed/resource.rc and b/test/resource.rc differ diff --git a/testbed/CMakeLists.txt b/testbed/CMakeLists.txt deleted file mode 100644 index 66c9427..0000000 --- a/testbed/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_executable(Testbed WIN32 main.cpp resource.rc)