Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <stdio.h>
- #define TD_WARNING_ICON MAKEINTRESOURCEW(-1)
- #define TD_ERROR_ICON MAKEINTRESOURCEW(-2)
- #define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3)
- #define TD_SHIELD_ICON MAKEINTRESOURCEW(-4)
- enum _TASKDIALOG_COMMON_BUTTON_FLAGS
- {
- TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK
- TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES
- TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO
- TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL
- TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY
- TDCBF_CLOSE_BUTTON = 0x0020 // selected control return value IDCLOSE
- };
- typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
- typedef HRESULT (*TaskDialog_t)(HWND, HINSTANCE, PCWSTR, PCWSTR, PCWSTR, TASKDIALOG_COMMON_BUTTON_FLAGS, PCWSTR, int*);
- int main(){
- HANDLE lib = LoadLibrary("Libs\\TaskDialog.dll");
- if(!lib){
- puts("Library not found!");
- return 1;
- }
- TaskDialog_t TaskDialog = (TaskDialog_t)GetProcAddress(lib, "TaskDialog");
- if(!TaskDialog){
- puts("Function in library not found!");
- FreeLibrary(lib);
- return 2;
- }
- int button_pressed = 0;
- if(TaskDialog(
- NULL, /* hWndParent */
- NULL, /* hInstance */
- L"TaskDialog - Title", /* pszWindowTitle */
- L"TaskDialog - Instruction", /* pszMainInstruction */
- L"TaskDialog - Content", /* pszContent */
- TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON, /* dwCommonButtons */
- TD_INFORMATION_ICON, /* pszIcon */
- &button_pressed /* *pnButton */
- ) != S_OK){
- puts("Function call failed!");
- FreeLibrary(lib);
- return 3;
- }
- puts(button_pressed == IDOK ? "OK" : "Cancel");
- FreeLibrary(lib);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement