| 1 | #include <windows.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 | #include <stdlib.h>
|
|---|
| 4 | #include <memory.h>
|
|---|
| 5 |
|
|---|
| 6 | #ifndef _MSC_VER
|
|---|
| 7 |
|
|---|
| 8 | #include <odinlx.h>
|
|---|
| 9 |
|
|---|
| 10 | int _main(int argc, char **argv);
|
|---|
| 11 |
|
|---|
| 12 | int WIN32API WinMain(HANDLE hInstance,
|
|---|
| 13 | HANDLE hPrevInstance,
|
|---|
| 14 | LPSTR lpCmdLine,
|
|---|
| 15 | int nCmdShow)
|
|---|
| 16 | {
|
|---|
| 17 | return _main(__argcA, __argvA);
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | int main(int argc, char **argv)
|
|---|
| 21 | {
|
|---|
| 22 | EnableSEH();
|
|---|
| 23 | RegisterLxExe(WinMain, NULL);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | #else
|
|---|
| 27 | #define _main main
|
|---|
| 28 | #endif
|
|---|
| 29 |
|
|---|
| 30 | int _main(int argc, char **argv)
|
|---|
| 31 | {
|
|---|
| 32 | STARTUPINFO si;
|
|---|
| 33 | PROCESS_INFORMATION pi;
|
|---|
| 34 | BOOL rc;
|
|---|
| 35 | char *cmd;
|
|---|
| 36 |
|
|---|
| 37 | /* ANSI encoding */
|
|---|
| 38 | MessageBoxA(NULL,
|
|---|
| 39 | "ANSI: Ðóññêèé 1251, ãá᪚© 866",
|
|---|
| 40 | "ANSI: Ðóññêèé 1251, ãá᪚© 866",
|
|---|
| 41 | MB_ICONINFORMATION | MB_OK);
|
|---|
| 42 |
|
|---|
| 43 | /* Unicode */
|
|---|
| 44 | MessageBoxW(NULL,
|
|---|
| 45 | L"Unicode: \x0420\x0443\x0441\x0441\x043a\x0438\x0439",
|
|---|
| 46 | L"Unicode: \x0420\x0443\x0441\x0441\x043a\x0438\x0439",
|
|---|
| 47 | MB_ICONINFORMATION | MB_OK);
|
|---|
| 48 |
|
|---|
| 49 | /* Command line */
|
|---|
| 50 | printf("1st Command Line argument: \"%s\"\n", argc > 1 ? argv[1] : NULL);
|
|---|
| 51 | MessageBoxA(NULL,
|
|---|
| 52 | argc > 1 ? argv[1] : NULL,
|
|---|
| 53 | "1st Command Line argument",
|
|---|
| 54 | MB_ICONINFORMATION | MB_OK);
|
|---|
| 55 |
|
|---|
| 56 | /* Start a command */
|
|---|
| 57 | memset(&pi, 0, sizeof(pi));
|
|---|
| 58 | memset(&si, 0, sizeof(si));
|
|---|
| 59 | si.cb = sizeof(si);
|
|---|
| 60 | cmd = getenv("COMSPEC");
|
|---|
| 61 | rc = CreateProcess(cmd, "cmd.exe /c òåñò.cmd", NULL, NULL, FALSE, 0,
|
|---|
| 62 | NULL, NULL, &si, &pi);
|
|---|
| 63 | printf("CreateProcess returned %d (error %x)\n", rc, GetLastError());
|
|---|
| 64 | if (rc) {
|
|---|
| 65 | printf("dwProcessId %d\n", pi.dwProcessId);
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | return 0;
|
|---|
| 69 | }
|
|---|