Commit 11216891 authored by captainwong's avatar captainwong

update

parent 0bc24748
......@@ -55,13 +55,8 @@ inline void init_logger(const std::wstring& file_name = L"")
sinks.push_back(std::make_shared<spdlog::sinks::msvc_sink_mt>());
#endif
sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>());
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>(
#ifdef WIN32
file_name + L".log"
#else
file_name + ".log"
#endif
, 23, 59));
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>(file_name + L".log", 23, 59));
auto combined_logger = std::make_shared<spdlog::logger>(g_logger_name, begin(sinks), end(sinks));
combined_logger->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [tid %t] [%L] %v");
spdlog::register_logger(combined_logger);
......
......@@ -441,10 +441,31 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
{
bool ok = false;
// 初始化COM
HRESULT hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
// 初始化COM COINIT_APARTMENTTHREADED
HRESULT hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hres)) {
return false;
#ifndef __AFXWIN_H__
_com_error ce(hres);
qDebug() << "CoInitializeEx with COINIT_MULTITHREADED failed:\n" << ce.Error() << QString::fromWCharArray(ce.ErrorMessage()); //
#endif
if (hres == 0x80010106) {
#ifndef __AFXWIN_H__
qDebug() << "already initilized, pass"; //
#endif
} else {
#ifndef __AFXWIN_H__
qDebug() << "trying CoInitializeEx with COINIT_APARTMENTTHREADED"; //
#endif
hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoInitializeEx with COINIT_APARTMENTTHREADED failed, exit";
#endif
return false;
}
}
}
// 设置COM的安全认证级别
......@@ -460,6 +481,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
NULL
);
if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoInitializeSecurity:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
CoUninitialize();
return false;
}
......@@ -474,6 +498,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
reinterpret_cast<LPVOID*>(&pLoc)
);
if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoCreateInstance:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
CoUninitialize();
return false;
}
......@@ -491,8 +518,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
&pSvc
);
if (FAILED(hres)) {
_com_error e(hres);
e.ErrorMessage();
#ifndef __AFXWIN_H__
qDebug() << "ConnectServer:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
pLoc->Release();
CoUninitialize();
return false;
......@@ -510,6 +538,9 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
EOAC_NONE
);
if (FAILED(hres)) {
#ifndef __AFXWIN_H__
qDebug() << "CoSetProxyBlanket:" << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
pSvc->Release();
pLoc->Release();
CoUninitialize();
......@@ -537,6 +568,10 @@ static bool query(const std::vector<QueryType>& queryTypes, std::unordered_map<Q
//pSvc->Release();
//pLoc->Release();
//CoUninitialize();
#ifndef __AFXWIN_H__
qDebug() << "ExecQuery:\n" << QString::fromWCharArray(query.szSelect) << '\n' << QString::fromWCharArray(_com_error(hres).ErrorMessage());
#endif
results[queryType] = _com_error(hres).ErrorMessage();
continue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment