-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathxlframework.h
97 lines (74 loc) · 1.81 KB
/
xlframework.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
///***************************************************************************
// File: FRAMEWRK.H
//
// Purpose: Header file for Framework library
//
// Platform: Microsoft Windows
//
// Comments:
// Include this file in any source files
// that use the framework library.
//
// From the Microsoft Excel Developer's Kit, Version 12
// Copyright (c) 1997 - 2007 Microsoft Corporation. All rights reserved.
///***************************************************************************
#pragma once
#include <wchar.h>
#include "xlmemorymanager.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;
}
extern "C" LPXLOPER12 TempErr12(int err)
{
LPXLOPER12 lpx;
lpx = (LPXLOPER12)GetTempMemory(sizeof(XLOPER12));
if (!lpx)
{
return 0;
}
lpx->xltype = xltypeErr;
lpx->val.err = err;
return lpx;
}
LPXLOPER12 TempNum12(double d)
{
LPXLOPER12 lpx;
lpx = (LPXLOPER12)GetTempMemory(sizeof(XLOPER12));
if (!lpx)
{
return 0;
}
lpx->xltype = xltypeNum;
lpx->val.num = d;
return lpx;
}