void HandleKey( int keycode, int bDown ) { char c = toupper( keycode ); if( c == 'D' && bDown ) show_debug = !show_debug; if( c == 'W' ) force_white = bDown; if( c == '9' && bDown ) { gKey--; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); } if( c == '-' && bDown ) { gKey++; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); } if( c == '0' && bDown ) { gKey = 0; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); } if( c == 'E' && bDown ) show_debug_basic = !show_debug_basic; if( c == 'K' && bDown ) DumpParameters(); if( keycode == 65307 ) exit( 0 ); printf( "Key: %d -> %d\n", keycode, bDown ); KeyHappened( keycode, bDown ); }
int wmain(int argc, WCHAR* argv[]) { WCHAR shortcutPathStr[MAX_PATH]; WCHAR targetPathStr[MAX_PATH]; WCHAR appModelIDStr[MAX_PATH]; WCHAR descriptionStr[MAX_PATH]; shortcutPathStr[0] = '\0'; targetPathStr[0] = '\0'; appModelIDStr[0] = '\0'; descriptionStr[0] = '\0'; bool createShortcutFound = false; bool updateFound = false; bool shortcutPathFound = false; bool targetPathFound = false; bool appModelIDFound = false; bool modeFound = false; bool descriptionFound = false; bool printFound = false; int idx; for (idx = 1; idx < argc; idx++) { if (!wcscmp(L"/CREATE", argv[idx])) { createShortcutFound = true; continue; } if (!wcscmp(L"/UPDATE", argv[idx])) { updateFound = true; continue; } if (!wcscmp(L"/PRINT", argv[idx])) { printFound = true; continue; } if (!wcsncmp(L"/S", argv[idx], 2) && wcslen(argv[idx]) > 2) { wcscpy_s(shortcutPathStr, MAX_PATH, (argv[idx]+2)); shortcutPathFound = true; continue; } if (!wcsncmp(L"/T", argv[idx], 2) && wcslen(argv[idx]) > 2) { wcscpy_s(targetPathStr, MAX_PATH, (argv[idx]+2)); targetPathFound = true; continue; } if (!wcsncmp(L"/A", argv[idx], 2) && wcslen(argv[idx]) > 2) { wcscpy_s(appModelIDStr, MAX_PATH, (argv[idx]+2)); appModelIDFound = true; continue; } if (!wcsncmp(L"/D", argv[idx], 2) && wcslen(argv[idx]) > 2 && wcslen(argv[idx]) < MAX_PATH) { wcscpy_s(descriptionStr, MAX_PATH, (argv[idx]+2)); descriptionFound = true; continue; } if (!wcscmp(L"/M", argv[idx])) { modeFound = true; continue; } } DumpParameters(targetPathStr, shortcutPathStr, appModelIDStr, descriptionStr); if (!createShortcutFound && !updateFound && !printFound) { DumpCommands(); return 0; } if (!targetPathFound) { printf("missing target file path.\n"); return -1; } HRESULT hres; if (printFound) { if (FAILED(hres = PrintShortcutProps(targetPathStr))) { printf("failed printing target props HRESULT=%X\n", hres); return -1; } return 0; } if (createShortcutFound && !shortcutPathFound) { printf("missing shortcut file path.\n"); return -1; } if (updateFound && !appModelIDFound && !modeFound) { printf("no properties selected.\n"); return -1; } if (createShortcutFound) { if (FAILED(hres = CreateLink(targetPathStr, shortcutPathStr, (descriptionFound ? descriptionStr : nullptr)))) { printf("failed creating shortcut HRESULT=%X\n", hres); return -1; } } LPCWSTR target; if (createShortcutFound) { target = shortcutPathStr; } else { target = targetPathStr; } if (appModelIDFound || modeFound) { if (FAILED(hres = SetShortcutProps(target, (appModelIDFound ? appModelIDStr : nullptr), appModelIDFound, modeFound))) { printf("failed adding property HRESULT=%X\n", hres); return -1; } } return 0; }