1 Star 0 Fork 47

zhangminjie / openGauss-connector-odbc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
xalibname.c 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
/*------
* Module: xalibname.c
*
* Description:
* This module gets the (path) name of xalib.
*
*-------
*/
#ifdef _HANDLE_ENLIST_IN_DTC_
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif /* _WIN32_WINNT */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
extern HMODULE s_hModule;
static char xalibpath[_MAX_PATH] = "";
static char xalibname[_MAX_FNAME] = "";
static const char * const PGMFILES = "Program Files";
static const char * const PGMFILESX86 = "Program Files (x86)";
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process;
BOOL IsWow64()
{
static BOOL bCalled = FALSE;
static BOOL bIsWow64 = FALSE;
if (bCalled)
return bIsWow64;
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
GetModuleHandle("kernel32"), "IsWow64Process");
if (NULL != fnIsWow64Process)
{
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
{
//handle error
}
}
bCalled = TRUE;
return bIsWow64;
}
const char *GetXaLibName(void)
{
char dllpath[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
fname[_MAX_FNAME], ext[_MAX_EXT];
if (!xalibpath[0])
{
size_t pgmflen = strlen(PGMFILESX86);
char *ptr;
GetModuleFileName(s_hModule, dllpath, sizeof(dllpath));
/* In Windows XP SP2, the dllname should be specified */
/* instead of the dll path name, because it looks up */
/* the HKLM\Microfost\MSDTC\XADLL\(dllname) registry */
/* entry for security reason. */
_splitpath(dllpath, drive, dir, fname, ext);
strncpy(xalibname, "pgxalib.dll", sizeof(xalibname));
if (IsWow64())
{
if ('\\' == *dir &&
0 == _strnicmp(dir + 1, PGMFILESX86, pgmflen))
{
ptr = dir + 1 + pgmflen;
if ('\\' == *ptr)
_snprintf(xalibpath, sizeof(xalibpath), "%s\\%s%s%s", drive, PGMFILES, ptr, xalibname);
}
}
else
_snprintf(xalibpath, sizeof(xalibpath), "%s%s%s", drive, dir, xalibname);
}
return xalibname;
}
const char *GetXaLibPath(void)
{
GetXaLibName();
return xalibpath;
}
#endif /* _HANDLE_ENLIST_IN_DTC_ */
C
1
https://gitee.com/zhangminjie1997/openGauss-connector-odbc.git
git@gitee.com:zhangminjie1997/openGauss-connector-odbc.git
zhangminjie1997
openGauss-connector-odbc
openGauss-connector-odbc
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891