22 #include <freerdp/config.h>
24 #include <winpr/windows.h>
26 #include <winpr/crt.h>
28 #include <freerdp/freerdp.h>
29 #include <freerdp/constants.h>
31 #include <freerdp/client/file.h>
32 #include <freerdp/client/cmdline.h>
33 #include <freerdp/client/channels.h>
34 #include <freerdp/channels/channels.h>
36 #include "../resource/resource.h"
38 #include <wf_client.h>
39 #include <wf_defaults.h>
43 INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
50 rdpSettings* settings;
53 RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 };
58 WINPR_UNUSED(hInstance);
59 WINPR_UNUSED(hPrevInstance);
60 WINPR_UNUSED(lpCmdLine);
61 WINPR_UNUSED(nCmdShow);
63 RdpClientEntry(&clientEntryPoints);
64 context = freerdp_client_context_new(&clientEntryPoints);
69 cmd = GetCommandLineW();
74 args = CommandLineToArgvW(cmd, &argc);
76 if (!args || (argc <= 0))
79 argv = calloc((
size_t)argc,
sizeof(
char*));
84 for (
int i = 0; i < argc; i++)
86 int size = WideCharToMultiByte(CP_UTF8, 0, args[i], -1, NULL, 0, NULL, NULL);
89 argv[i] = calloc((
size_t)size,
sizeof(
char));
94 if (WideCharToMultiByte(CP_UTF8, 0, args[i], -1, argv[i], size, NULL, NULL) != size)
98 freerdp_client_warn_deprecated(argc, argv);
100 settings = context->settings;
101 wfc = (wfContext*)context;
103 if (!settings || !wfc)
106 status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE);
109 ret = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
113 AddDefaultSettings(settings);
115 if (freerdp_client_start(context) != 0)
118 thread = freerdp_client_get_thread(context);
122 if (WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0)
124 GetExitCodeThread(thread, &dwExitCode);
125 ret = (int)dwExitCode;
129 if (freerdp_client_stop(context) != 0)
133 freerdp_client_context_free(context);
137 for (
int i = 0; i < argc; i++)
147 #ifdef WITH_WIN_CONSOLE
150 return WinMain(NULL, NULL, NULL, 0);