Impl get tables with sql
This commit is contained in:
@@ -174,6 +174,27 @@ BSTR *RpcGetDbNames(int *pNum)
|
||||
return pBstr;
|
||||
}
|
||||
|
||||
PPRpcTables RpcGetDbTables(const wchar_t *db, int *pNum)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long ulCode = 0;
|
||||
PPRpcTables ppRpcTables = NULL;
|
||||
|
||||
RpcTryExcept { ret = client_GetDbTables(db, pNum, &ppRpcTables); }
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("RpcGetDbTables exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
if (ret != 0) {
|
||||
printf("RpcGetDbTables Failed: %d\n", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ppRpcTables;
|
||||
}
|
||||
|
||||
int server_ReceiveMsg(RpcMessage_t rpcMsg)
|
||||
{
|
||||
WxMessage_t msg;
|
||||
|
||||
@@ -12,3 +12,4 @@ int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path);
|
||||
PPRpcIntBstrPair RpcGetMsgTypes(int *pNum);
|
||||
PPRpcContact RpcGetContacts(int *pNum);
|
||||
BSTR *RpcGetDbNames(int *pNum);
|
||||
PPRpcTables RpcGetDbTables(const wchar_t *db, int *pNum);
|
||||
|
||||
+21
@@ -187,3 +187,24 @@ std::vector<std::wstring> WxGetDbNames()
|
||||
|
||||
return vDbs;
|
||||
}
|
||||
|
||||
DbTableVector_t WxGetDbTables(wstring db)
|
||||
{
|
||||
DbTableVector_t vTables;
|
||||
int size = 0;
|
||||
PPRpcTables pp = RpcGetDbTables(db.c_str(), &size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
WxDbTable_t tbl;
|
||||
tbl.table = GetWstringFromBstr(pp[i]->table);
|
||||
tbl.sql = GetWstringFromBstr(pp[i]->sql);
|
||||
|
||||
vTables.push_back(tbl);
|
||||
midl_user_free(pp[i]);
|
||||
}
|
||||
|
||||
if (pp) {
|
||||
midl_user_free(pp);
|
||||
}
|
||||
|
||||
return vTables;
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,4 +5,5 @@
|
||||
WxGetMsgTypes
|
||||
WxSendImageMsg
|
||||
WxGetContacts
|
||||
WxGetDbNames
|
||||
WxGetDbNames
|
||||
WxGetDbTables
|
||||
|
||||
@@ -28,8 +28,14 @@ typedef struct WxContact {
|
||||
wstring wxGender; // 性别
|
||||
} WxContact_t;
|
||||
|
||||
typedef struct WxDbTable {
|
||||
wstring table; // 表名
|
||||
wstring sql; // 建表 SQL
|
||||
} WxDbTable_t;
|
||||
|
||||
typedef map<int, wstring> MsgTypesMap_t;
|
||||
typedef map<wstring, WxContact_t> ContactMap_t;
|
||||
typedef vector<WxDbTable_t> DbTableVector_t;
|
||||
|
||||
int WxInitSDK();
|
||||
int WxSetTextMsgCb(const std::function<int(WxMessage_t)> &onMsg);
|
||||
@@ -38,3 +44,4 @@ int WxSendImageMsg(wstring wxid, wstring path);
|
||||
ContactMap_t WxGetContacts();
|
||||
MsgTypesMap_t WxGetMsgTypes();
|
||||
vector<wstring> WxGetDbNames();
|
||||
DbTableVector_t WxGetDbTables(wstring db);
|
||||
|
||||
@@ -187,6 +187,15 @@ wstring GetWstringFromBstr(BSTR p)
|
||||
return ws;
|
||||
}
|
||||
|
||||
BSTR GetBstrFromString(const char *str)
|
||||
{
|
||||
int wslen = MultiByteToWideChar(CP_ACP, 0, str, strlen(str), 0, 0);
|
||||
BSTR bstr = SysAllocStringLen(0, wslen);
|
||||
MultiByteToWideChar(CP_ACP, 0, str, strlen(str), bstr, wslen);
|
||||
|
||||
return bstr;
|
||||
}
|
||||
|
||||
BSTR GetBstrFromWstring(wstring ws)
|
||||
{
|
||||
if (!ws.empty()) {
|
||||
|
||||
@@ -24,5 +24,6 @@ BSTR GetBstrByAddress(DWORD address);
|
||||
void GetRpcMessage(WxMessage_t *wxMsg, RpcMessage_t rpcMsg);
|
||||
DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address);
|
||||
std::wstring GetWstringFromBstr(BSTR p);
|
||||
BSTR GetBstrFromString(const char *str);
|
||||
BSTR GetBstrFromWstring(std::wstring ws);
|
||||
std::wstring GetUnicodeInfoByAddress(HANDLE hProcess, DWORD address);
|
||||
|
||||
Reference in New Issue
Block a user