/
xalibname.c
51 lines (43 loc) · 1.16 KB
/
xalibname.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*------
* 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] = "";
const char *GetXaLibName()
{
char dllpath[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
fname[_MAX_FNAME], ext[_MAX_EXT];
if (!xalibpath[0])
{
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);
// _snprintf(xalibname, sizeof(xalibname), "%s%s", fname, ext);
strcpy(xalibname, "pgxalib.dll");
_snprintf(xalibpath, sizeof(xalibpath), "%s%s%s", drive, dir, xalibname);
}
return xalibname;
}
const char *GetXaLibPath()
{
GetXaLibName();
return xalibpath;
}
#endif /* _HANDLE_ENLIST_IN_DTC_ */