-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGetExeType.cpp
More file actions
24 lines (21 loc) · 859 Bytes
/
GetExeType.cpp
File metadata and controls
24 lines (21 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <Windows.h>
#include <ShellApi.h>
#include <cstdio>
#include <tchar.h>
int _tmain(const int /*argc*/, const TCHAR* const argv[])
{
//_ftprintf(stderr, TEXT("File: %s\n"), argv[1]);
const DWORD Type = (DWORD) SHGetFileInfo(argv[1], 0, nullptr, 0, SHGFI_EXETYPE);
const DWORD Error = GetLastError();
if (Error != 0)
_ftprintf(stderr, TEXT("SHGetFileInfo Error: 0x%08X\n"), Error);
if (LOWORD(Type) == MAKEWORD('P', 'E') && HIWORD(Type) == 0)
_ftprintf(stdout, TEXT("Console application\n"));
else if (LOWORD(Type) == MAKEWORD('P', 'E'))
_ftprintf(stdout, TEXT("Windows application\n"));
else if (LOWORD(Type) == MAKEWORD('M', 'Z') && HIWORD(Type) == 0)
_ftprintf(stdout, TEXT("MS-DOS application\n"));
else
_ftprintf(stdout, TEXT("Unknown type\n"));
return EXIT_SUCCESS;
}