添加URLProtocol

添加URLProtocol
pull/125/head
horizonlin 2018-12-18 11:46:00 +08:00 committed by GitHub
parent 219e4bc8e9
commit b3645244ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 4 deletions

View File

@ -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.