view msgup/msgup.c @ 632:882ed7909868

Show seconds in Windows clock. Works starting with Windows 10 build 14393.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Wed, 05 Apr 2017 15:12:30 +0300
parents 68e193dd6a32
children
line wrap: on
line source

/* -*- coding: utf-8 -*- */

#include <wchar.h>
#include <stdio.h>
#include <windows.h>

#define PROGRAM "msgup"
#define PACKAGE "MYUTILS"
#define VERSION "0.1"

void print_version(void)
{
    puts(PROGRAM " (" PACKAGE ") " VERSION);
    puts("Copyright (C) 2010 Oleksandr Gavenko.");
    puts("License X11 <http://www.opensource.org/licenses/mit-license.php>.");
    puts("The software prowided \"AS IS\", without any warranty.");
}

void print_help(void)
{
    puts("Usage:");
    puts("  " PROGRAM " <title> <message>");
    puts("Options:");
    puts("  --help            print this help");
    puts("  --version         print version info");
}

int WINAPI WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    PSTR szCmdLine,
                    int iCmdShow)
{
    int argc;
    LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);

    for (int i = 1; i < argc; i++) {
        if (!wcscmp(L"--version", argv[i])) {
            print_version();
            return EXIT_SUCCESS;
        }
        if (!wcscmp(L"--help", argv[i])) {
            print_help();
            return EXIT_SUCCESS;
        }
    }

    if (argc != 3) {
        MessageBoxW(NULL, L"You must supply exactly 2 argument!\nUsage:\n    " PROGRAM " <title> <message>", L"Error", MB_ICONERROR);
        return EXIT_FAILURE;
    }

    MessageBoxW(NULL, argv[2], argv[1], MB_ICONINFORMATION);

    return EXIT_SUCCESS;
}