Beispiel #1
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg) {
		case WM_CLOSE:
			DestroyWindow(hWnd);
			return TRUE;
		case WM_DESTROY:
			PostQuitMessage(0);
			return TRUE;
		case WM_COMMAND:
			if (LOWORD(wParam) == IDB_CLOSE) {
				PostQuitMessage(0);
				return TRUE;
			}
			if (LOWORD(wParam) == IDB_INSTALL) {
				if (installDriver(hWnd)) {
					if (CMIKeysExist()) {
						if (MessageBox(hWnd, "The driver has been successfully installed! Do you want to remove the remains of the official C-Media driver?", "Driver Installer", MB_ICONINFORMATION | MB_YESNO) == IDYES) {
							deleteCMIKeys();
						}
					} else {
						MessageBox(hWnd, "The driver has been successfully installed!", "Driver Installer", MB_ICONINFORMATION);
					}
					writeUninstallerKeys();
					PostQuitMessage(0);
				}

				return TRUE;
			}
	}
	return 0;
}
int main(int argc, char **argv)
{
    bool installMode;
#ifdef TESTMODE
    bool testMode = false;
#endif

    if (argc != 2)
    {
        displayHelpAndExit(argv[0]);
    }
    if (strcmp(argv[1], "install") == 0)
    {
        installMode = true;
    } else
    if (strcmp(argv[1], "uninstall") == 0)
    {
        installMode = false;
    } else
#ifdef TESTMODE
    if (strcmp(argv[1], "test") == 0)
    {
        testMode = true;
    } else
#endif
    {
        displayHelpAndExit(argv[0]);
    }

    int rc;

#ifdef TESTMODE
    if (testMode)
    {
        rc = performTest();
    } else
#endif
    if (installMode)
    {
        rc = installDriver();
    } else
    {
        rc = uninstallDriver();
    }

    if (rc == 0)
    {
        printf("operation completed successfully!\n");
    } else
    {
        printf("error: operation failed with status code %d\n", rc);
    }

    return rc;
}
int main(int argc, char **argv)
{
    bool installMode;
#ifdef TESTMODE
    bool testMode = false;
#endif

    if (argc != 2)
        return usage(argv[0]);

    if (strcmp(argv[1], "install") == 0)
        installMode = true;
    else if (strcmp(argv[1], "uninstall") == 0)
        installMode = false;
#ifdef TESTMODE
    else if (strcmp(argv[1], "test") == 0)
        testMode = true;
#endif
    else
        return usage(argv[0]);


    int rc;
#ifdef TESTMODE
    if (testMode)
        rc = performTest();
    else
#endif
    if (installMode)
        rc = installDriver();
    else
        rc = uninstallDriver();

    if (rc == 0)
        printf("operation completed successfully!\n");
    else
        printf("error: operation failed with status code %d\n", rc);

    return rc;
}