mirror of
https://github.com/donnaskiez/ac.git
synced 2024-11-21 22:24:08 +01:00
bed timeee
This commit is contained in:
parent
7d5714a982
commit
27eb9b9977
4 changed files with 53 additions and 8 deletions
50
testcli/main.cpp
Normal file
50
testcli/main.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <tlhelp32.h>
|
||||
|
||||
DWORD find_process_by_id(int id)
|
||||
{
|
||||
PROCESSENTRY32 entry = { 0 };
|
||||
entry.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
|
||||
while (Process32Next(snapshot, &entry))
|
||||
{
|
||||
if (entry.th32ProcessID == id)
|
||||
{
|
||||
return entry.th32ProcessID;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(snapshot);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
std::cerr << "Please enter a valid Process ID.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const std::vector<std::string_view> args(argv + 1, argv + argc);
|
||||
|
||||
DWORD id = find_process_by_id(std::stoi(args[0].data()));
|
||||
|
||||
if (!id)
|
||||
{
|
||||
std::cerr << "Process for the given process ID does not exist" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << id << std::endl;
|
||||
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
}
|
|
@ -118,6 +118,7 @@
|
|||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -127,7 +128,7 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="testcli.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="testcli.cpp">
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue