| 29 | char gPreferencesRegistryPath[MAX_PATH] = "SOFTWARE\\moddable.tech\\"; |
| 30 | |
| 31 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) |
| 32 | { |
| 33 | wchar_t* commandLine = GetCommandLineW(); |
| 34 | int argc = 0, argi; |
| 35 | LPWSTR* argv = CommandLineToArgvW(commandLine, &argc); |
| 36 | char buffer[MAX_PATH]; |
| 37 | GetModuleFileName(NULL, buffer, MAX_PATH); |
| 38 | char* name = strrchr(buffer, '\\') + 1; |
| 39 | char* dot = strrchr(buffer, '.'); |
| 40 | *dot = 0; |
| 41 | |
| 42 | HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, 0, name); |
| 43 | if (hMutex) { |
| 44 | HWND window = FindWindow("PiuWindow", name); |
| 45 | if ((nCmdShow != SW_SHOWMINIMIZED) && (nCmdShow != SW_MINIMIZE) && (nCmdShow != SW_SHOWMINNOACTIVE)) |
| 46 | SetForegroundWindow(window); |
| 47 | for (argi = 1; argi < argc; argi++) { |
| 48 | wchar_t path[MAX_PATH]; |
| 49 | COPYDATASTRUCT cds; |
| 50 | _wfullpath(path, argv[argi], MAX_PATH); |
| 51 | cds.cbData = 2 * (wcslen(path) + 1); |
| 52 | cds.lpData = path; |
| 53 | SendMessage(window, WM_COPYDATA, 0, (LPARAM)&cds); |
| 54 | } |
| 55 | return 0; |
| 56 | } |
| 57 | hMutex = CreateMutex(0, 0, name); |
| 58 | strcat(gWindowRegistryPath, name); |
| 59 | strcat(gWindowRegistryPath, "\\window"); |
| 60 | strcat(gPreferencesRegistryPath, name); |
| 61 | strcat(gPreferencesRegistryPath, "\\preferences"); |
| 62 | |
| 63 | ULONG_PTR m_gdiplusToken; |
| 64 | GdiplusStartupInput gdiplusStartupInput; |
| 65 | GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); |
| 66 | |
| 67 | INITCOMMONCONTROLSEX initCtrls = { sizeof(INITCOMMONCONTROLSEX), ICC_STANDARD_CLASSES }; |
| 68 | InitCommonControlsEx(&initCtrls); |
| 69 | |
| 70 | UINT dwErrMode; |
| 71 | dwErrMode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); |
| 72 | OleInitialize(NULL); |
| 73 | SetErrorMode(dwErrMode); |
| 74 | |
| 75 | gInstance = hInstance; |
| 76 | |
| 77 | WNDCLASSEX wcex; |
| 78 | wcex.cbSize = sizeof(WNDCLASSEX); |
| 79 | wcex.style = CS_HREDRAW | CS_VREDRAW; |
| 80 | wcex.lpfnWndProc = PiuWindowProc; |
| 81 | wcex.cbClsExtra = 0; |
| 82 | wcex.cbWndExtra = sizeof(PiuView*); |
| 83 | wcex.hInstance = gInstance; |
| 84 | wcex.hIcon = LoadIcon(gInstance, MAKEINTRESOURCE(100)); |
| 85 | wcex.hIconSm = NULL; |
| 86 | wcex.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 87 | wcex.hbrBackground = NULL; |
| 88 | wcex.lpszMenuName = NULL; |
nothing calls this directly
no test coverage detected