-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinMain.c
39 lines (31 loc) · 1.47 KB
/
WinMain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <initguid.h>
#include <windows.h>
#include <appmodel.h>
#include <shobjidl.h>
int WinMainCRTStartup()
{
INT NumArgs = 0;
LPWSTR *ArgvW = CommandLineToArgvW(GetCommandLineW(), &NumArgs);
CoInitialize(NULL);
IPackageDebugSettings *pPackageDebugSettings = NULL;
CoCreateInstance(&CLSID_PackageDebugSettings, NULL, CLSCTX_INPROC_SERVER, &IID_IPackageDebugSettings,
(LPVOID *)&pPackageDebugSettings);
for (INT nArg = 0; nArg < NumArgs; nArg++)
{
UINT32 count = 0, bufferLength = 0;
PCWSTR packageFamilyName = ArgvW[nArg];
pPackageDebugSettings->lpVtbl->EnableDebugging(pPackageDebugSettings, packageFamilyName, NULL, NULL);
if (GetPackagesByPackageFamily(packageFamilyName, &count, NULL, &bufferLength, NULL) !=
ERROR_INSUFFICIENT_BUFFER)
continue;
PWSTR *packageFullNames = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PWSTR) * count),
buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR) * bufferLength);
if (!GetPackagesByPackageFamily(packageFamilyName, &count, packageFullNames, &bufferLength, buffer))
for (UINT32 nIndex = 0; nIndex < count; nIndex++)
pPackageDebugSettings->lpVtbl->EnableDebugging(pPackageDebugSettings, packageFullNames[nIndex], NULL,
NULL);
}
ExitProcess(0);
return 0;
}