From b3645244baa7d654faa0ceac4452107f974cd13d Mon Sep 17 00:00:00 2001 From: horizonlin Date: Tue, 18 Dec 2018 11:46:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0URLProtocol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加URLProtocol --- client/tp_assist_win/tp_assist.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/client/tp_assist_win/tp_assist.cpp b/client/tp_assist_win/tp_assist.cpp index 262e1ad..03bbbf5 100644 --- a/client/tp_assist_win/tp_assist.cpp +++ b/client/tp_assist_win/tp_assist.cpp @@ -88,16 +88,35 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd if (0 == g_ulSingleInstanceMsgId) return FALSE; - LPWSTR szCmdLine=(LPWSTR)::GetCommandLineW(); //ȡв - g_argv=CommandLineToArgvW(szCmdLine, &g_argc); //вַ - + LPWSTR szCmdLine=(LPWSTR)::GetCommandLineW(); //获取命令行参数; + g_argv=CommandLineToArgvW(szCmdLine, &g_argc); //拆分命令行参数字符串; + std::wstring arg; for (int i=0; i < g_argc; ++i) { + arg = g_argv[i]; if (0 == lstrcmp(g_argv[i], _T("--stop"))) { PostMessage(HWND_BROADCAST, g_ulSingleInstanceMsgId, WMU_INSTANCE_EXIT, 0); LocalFree(g_argv); g_argv=NULL; return -1; - } + }else if (arg.find(L"teleport_ip",0) !=std::wstring::npos && arg.find(L"teleport_port") != std::wstring::npos && arg.find(L"remote_host_ip") != std::wstring::npos && arg.find(L"session_id") != std::wstring::npos) { + //把wchar_t **转换为std::string + size_t len = wcslen(g_argv[i]) + 1; + size_t converted = 0; + char *CStr; + CStr = (char*)malloc(len * sizeof(char)); + wcstombs_s(&converted, CStr, len, g_argv[i], _TRUNCATE); + std::string func_args = CStr; + + //调用TsHttpRpc类里的_rpc_func_run_client启动客户端 + TsHttpRpc ts_http_rpc; + ex_astr buf; + ts_http_rpc._rpc_func_url_protocol(func_args, buf); + + free(CStr); + LocalFree(g_argv); + g_argv = NULL; + return 0; + } } // make sure run single instance.