-
Notifications
You must be signed in to change notification settings - Fork 7
/
xlcall.cpp
109 lines (89 loc) · 1.94 KB
/
xlcall.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
/*
** Microsoft Excel Developer's Toolkit
** Version 12.0
**
** File: INCLUDE\XLCALL.CPP
** Description: Code file for Excel 2007 callbacks
** Platform: Microsoft Windows
**
** This file defines the entry points
** which are used in the Microsoft Excel 2007 C API.
**
*/
#ifndef _WINDOWS_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include "xlcall.h"
/*
** Excel 12 entry points backwards compatible with Excel 11
**
** Excel12 and Excel12v ensure backwards compatibility with Excel 11
** and earlier versions. These functions will return xlretFailed when
** used to callback into Excel 11 and earlier versions
*/
#define cxloper12Max 255
#define EXCEL12ENTRYPT "MdCallBack12"
typedef int (PASCAL *EXCEL12PROC) (int xlfn, int coper, LPXLOPER12 *rgpxloper12, LPXLOPER12 xloper12Res);
HMODULE hmodule;
EXCEL12PROC pexcel12;
__forceinline void FetchExcel12EntryPt(void)
{
if (pexcel12 == NULL)
{
hmodule = GetModuleHandle(NULL);
if (hmodule != NULL)
{
pexcel12 = (EXCEL12PROC) GetProcAddress(hmodule, EXCEL12ENTRYPT);
}
}
}
int _cdecl Excel12(int xlfn, LPXLOPER12 operRes, int count, ...)
{
#ifdef _WIN64
return(xlretFailed);
#else
LPXLOPER12 rgxloper12[cxloper12Max];
va_list ap;
int ioper;
int mdRet;
FetchExcel12EntryPt();
if (pexcel12 == NULL)
{
mdRet = xlretFailed;
}
else
{
mdRet = xlretInvCount;
if ((count >= 0) && (count <= cxloper12Max))
{
va_start(ap, count);
for (ioper = 0; ioper < count ; ioper++)
{
rgxloper12[ioper] = va_arg(ap, LPXLOPER12);
}
va_end(ap);
mdRet = (pexcel12)(xlfn, count, &rgxloper12[0], operRes);
}
}
return(mdRet);
#endif
}
int pascal Excel12v(int xlfn, LPXLOPER12 operRes, int count, LPXLOPER12 opers[])
{
#ifdef _WIN64
return(xlretFailed);
#else
int mdRet;
FetchExcel12EntryPt();
if (pexcel12 == NULL)
{
mdRet = xlretFailed;
}
else
{
mdRet = (pexcel12)(xlfn, count, &opers[0], operRes);
}
return(mdRet);
#endif
}