-
Notifications
You must be signed in to change notification settings - Fork 1
/
example1.c
68 lines (57 loc) · 1.9 KB
/
example1.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* This example is licensed under a Creative Commons Zero v1.0 Universal License
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
#include <Windows.h>
#include "wintoastlibc.h"
int main(int argc, char ** argv)
{
INT ret = EXIT_SUCCESS;
WTLC_Instance * instance = NULL;
WTLC_Template * templ = NULL;
WTLC_Error error = WTLC_Error_NoError;
if(!WTLC_isCompatible())
{
MessageBoxW(NULL, L"Your system is not compatible!", L"Error", MB_OK | MB_ICONERROR);
return EXIT_FAILURE;
}
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
MessageBoxW(NULL, L"COM library initialization failed!", L"Error", MB_OK | MB_ICONERROR);
return EXIT_FAILURE;
}
instance = WTLC_Instance_Create();
if(!instance)
{
MessageBoxW(NULL, L"WinToast instance creation failed!", L"Error", MB_OK | MB_ICONERROR);
ret = EXIT_FAILURE;
goto cleanup;
}
WTLC_setAppName(instance, L"Example");
WTLC_setAppUserModelId(instance, L"Microsoft.Windows.Explorer");
WTLC_setShortcutPolicy(instance, WTLC_SHORTCUT_POLICY_IGNORE);
if(!WTLC_initialize(instance, &error))
{
MessageBoxW(NULL, WTLC_strerror(error), L"Error", MB_OK | MB_ICONERROR);
ret = EXIT_FAILURE;
goto cleanup;
}
templ = WTLC_Template_Create(WTLC_TemplateType_Text01);
WTLC_Template_setFirstLine(templ, L"HELLO, WORLD!");
if(WTLC_showToast(instance, templ, NULL, NULL, NULL, NULL, NULL, &error) < 0)
{
MessageBoxW(NULL, WTLC_strerror(error), L"Error", MB_OK | MB_ICONERROR);
ret = EXIT_FAILURE;
goto cleanup;
}
Sleep(1000);
cleanup:
WTLC_Template_Destroy(templ);
WTLC_Instance_Destroy(instance);
CoUninitialize();
return ret;
}
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, INT nCmdShow)
{
return main(0, NULL);
}