Repository navigation
Expand file tree
/
Copy pathDDxll.cpp
More file actions
102 lines (85 loc) · 2.2 KB
/
Copy pathDDxll.cpp
File metadata and controls
102 lines (85 loc) · 2.2 KB
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
#include "DDxll.hpp"
#include "xllMain.h"
int DDxllAutoOpen(void)
{
return 0;
}
class ConnectZeroMQ {
public:
boost::shared_ptr<zmq::socket_t> zSocSub;
boost::shared_ptr<zmq::socket_t> zSocReq;
ConnectZeroMQ()
:zSocSub( new zmq::socket_t( *(new zmq::context_t(1)), ZMQ_SUB))
,zSocReq( new zmq::socket_t( *(new zmq::context_t(1)), ZMQ_REQ))
{
zSocSub->connect("epgm://10.88.88.128;239.192.1.11:5553");
zSocReq->connect("tcp://10.88.88.115:5555");
}
int conn()
{
}
int req(std::string s)
{
zSocReq->send(zmq::message_t(s.c_str(), s.length() + 1));
//zSocReq->recv();
}
};
//ConnectZeroMQ conn;
DWORD WINAPI DDSret(LPVOID args)
{
LPXLOPER12* opers = (LPXLOPER12*)args;
XLOPER12 xlResult;
// Simulate waiting for a long external operation.
Sleep(1000);
if (opers[0]->xltype & xltypeNum)
opers[0]->val.num *= 2;
int retval = Excel12(xlAsyncReturn, &xlResult, 2, opers[1], opers[0]);
// Free the passed pointer array
// (Excel itself calls xlAutoFree12 to free the XLOPERs, since they have xlbitDLLFree).
delete opers;
ExitThread(0);
return 0;
}
//void AsyncStubFailHelper(LPXLOPER12 asyncHandle)
//{
// //an error handler with no heap/thread operations.
// //used to send back #VALUE! when an async stub fails
// XLOPER12 operResult;
//
// XLOPER12 operErr;
// operErr.xltype = xltypeErr;
// operErr.val.err = xlerrValue;
//
// Excel12(xlAsyncReturn, &operResult, 2, asyncHandle, &operErr);
//}
void WINAPI DDS(LPXLOPER12 oper, LPXLOPER12 asyncHandle)
{
// point to the arguments from a pointer array that will be freed by XllEchoSetReturn
LPXLOPER12* argsArray = new LPXLOPER12[2];
if (argsArray == NULL)
{
AsyncStubFailHelper(asyncHandle);
return;
}
argsArray[0] = TempOper12(oper);
if (argsArray[0] == NULL)
{
delete argsArray;
AsyncStubFailHelper(asyncHandle);
}
argsArray[1] = TempOper12(asyncHandle);
if (argsArray[1] == NULL)
{
xlAutoFree12(argsArray[0]);
delete argsArray;
AsyncStubFailHelper(asyncHandle);
}
// Simulate an external async operation - start a thread and return.
if (CreateThread(NULL, 0, DDSret, argsArray, 0, NULL) == NULL)
{
xlAutoFree12(argsArray[1]);
xlAutoFree12(argsArray[0]);
delete argsArray;
AsyncStubFailHelper(asyncHandle);
}
}