#include #include #include int wmain(int argc,wchar_t **argv) { // A launch through the embedded terminal would inherit its console. DWORD consoleProcesses[1]{}; if(GetConsoleProcessList(consoleProcesses,1)>1) return 1; wchar_t executable[32768]{}; const auto length=GetModuleFileNameW(nullptr,executable,static_cast(std::size(executable))); if(!length || length>=std::size(executable)) return 1; const std::filesystem::path target=argc==2?argv[1]:executable; auto report=target; report+=L".opened"; std::ofstream result(report,std::ios::binary); result<<"opened"; return result?0:1; }