cygwin arg passing
| #include <Windows.h> | |
| #include <stdio.h> | |
| int main(void) { | |
| LPCWSTR applicationName = L"C:\\cygwin64\\bin\\echo.exe"; | |
| LPWSTR commandLine = L"-- -FOO=\\\"BAR\\\""; | |
| printf("# Using CommandLineToArgvW:\n"); | |
| LPWSTR *arg_list; | |
| int arg_count; | |
| WCHAR fullCommandLine[MAX_PATH] = L""; | |
| wcscat(fullCommandLine, applicationName); | |
| wcscat(fullCommandLine, L" "); | |
| wcscat(fullCommandLine, commandLine); | |
| arg_list = CommandLineToArgvW(fullCommandLine, &arg_count); | |
| for(int i=0; i<arg_count; i++) | |
| printf("%d: %ws\n", i, arg_list[i]); | |
| printf("# Using CreateProcessW and cygwin echo.exe:\n"); | |
| BOOL ret; | |
| PROCESS_INFORMATION pi; | |
| STARTUPINFOW si; | |
| si.cb = sizeof(si); | |
| ZeroMemory(&si, sizeof(si)); | |
| ZeroMemory(&pi, sizeof(pi)); | |
| ret = CreateProcessW( | |
| applicationName, commandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); | |
| return 0; | |
| } |
| # Using CommandLineToArgvW: | |
| 0: C:\cygwin64\bin\echo.exe | |
| 1: -- | |
| 2: -FOO="BAR" | |
| # Using CreateProcessW and cygwin echo.exe: | |
| -FOO=\BAR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment