22 #if (defined(COMPILER_MSVC) && defined(NDEBUG) && !defined(RDC_BUILD))
27 bool IsAConsolePort (HANDLE handle)
31 return (GetConsoleMode(handle, &mode) != 0);
34 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
37 char szPathToProgram[768];
44 GetModuleFileName (NULL, (LPSTR)szPathToProgram, (DWORD)
sizeof(szPathToProgram));
45 argv[0] =
new char[(strlen(szPathToProgram) + 1)];
49 LPWSTR lpwCmdLine = 0;
50 int count, nArgs, argc = 1;
51 size_t argStringLen = strlen(lpCmdLine);
54 strcpy (argv[0], szPathToProgram);
59 lpwCmdLine =
new wchar_t[argStringLen+1];
60 mbstowcs (lpwCmdLine, lpCmdLine, argStringLen+1);
62 LPWSTR* pwArgv = CommandLineToArgvW ((LPCWSTR)lpwCmdLine, &nArgs);
66 for (count = 1; count <= nArgs; count++)
68 int argChars = wcslen (pwArgv[count-1]);
69 if (0 != (argv[count] =
new char[(argChars+1)]))
72 wcstombs (argv[count], pwArgv[count-1], argChars+1);
87 FILE *pStdOut = 0, *pStdErr = 0;
88 BOOL bConsole = AttachConsole(ATTACH_PARENT_PROCESS);
89 HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
91 if ((bConsole) && (IsAConsolePort(hStdOut)))
93 pStdOut = freopen(
"CONOUT$",
"w", stdout );
94 pStdErr = freopen(
"CONOUT$",
"w", stderr );
107 INPUT_RECORD input_record;
109 input_record.EventType = KEY_EVENT;
110 input_record.Event.KeyEvent.bKeyDown = TRUE;
111 input_record.Event.KeyEvent.dwControlKeyState = 0;
112 input_record.Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
113 input_record.Event.KeyEvent.wRepeatCount = 1;
114 input_record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
115 input_record.Event.KeyEvent.wVirtualScanCode = MapVirtualKey( VK_RETURN, 0 );
118 WriteConsoleInput( GetStdHandle( STD_INPUT_HANDLE ), &input_record, 1, &written );
123 for (count = 0; count < argc; count++)
124 delete[] argv[count];
int ardour_main(int argc, char *argv[])