-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathframework.h
46 lines (35 loc) · 852 Bytes
/
framework.h
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
#include <wchar.h>
#include "memorymanager.h"
extern "C" LPSTR cdecl GetTempMemory(int cBytes)
{
return MGetTempMemory(cBytes);
}
extern "C" void cdecl FreeAllTempMemory(void)
{
MFreeAllTempMemory();
}
extern "C" int cdecl Excel12f(int xlfn, LPXLOPER12 pxResult, int count, ...)
{
int xlret = Excel12v(xlfn, pxResult, count, (LPXLOPER12 *)(&count + 1));
FreeAllTempMemory();
return xlret;
}
extern "C" LPXLOPER12 TempStr12(const XCHAR* lpstr)
{
LPXLOPER12 lpx;
XCHAR* lps;
int len;
len = lstrlenW(lpstr);
lpx = (LPXLOPER12)GetTempMemory(sizeof(XLOPER12) + (len + 1) * 2);
if (!lpx)
{
return 0;
}
lps = (XCHAR*)((CHAR*)lpx + sizeof(XLOPER12));
lps[0] = (BYTE)len;
//can't wcscpy_s because of removal of null-termination
wmemcpy_s(lps + 1, len + 1, lpstr, len);
lpx->xltype = xltypeStr;
lpx->val.str = lps;
return lpx;
}