forked from electronicarts/CnC_Tiberian_Dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDDE.H
175 lines (146 loc) · 6.99 KB
/
DDE.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
***************************************************************************
* *
* Project Name : Dynamic Data Encapsulation *
* *
* File Name : DDE.H *
* *
* Programmer : Steve Wetherill *
* *
* Start Date : June 1, 1996 *
* *
* Last Update : June 8, 1996 [SW] *
* *
*-------------------------------------------------------------------------*
* *
* This is the DDE (Instance_Class) which provides a simple CLIENT/SERVER *
* DDE model for data transactions between Windows applications. *
* This is a fairly naieve implementation allowing only one client/server *
* per Instance_Class object. *
* *
* Typical uses for this class are: *
* *
* i. Robust verification of whether an application is running *
* ii. Data transfer between applications *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
***************************** Class defines *****************************
*/
#ifndef __DDE_H
#define __DDE_H
#define DDE_ADVISE_CONNECT -1 // advisory "client has connected"
#define DDE_ADVISE_DISCONNECT -2 // advisory "client has disconnected"
/*
***************************** Class Declaration *****************************
*/
class Instance_Class {
/*
---------------------------- Public Interface ----------------------------
*/
public:
/*.....................................................................
Constructor:
- takes null terminated ASCII strings names for client and server
.....................................................................*/
Instance_Class( // constructor
LPSTR, // null terminated local sever name string
LPSTR // null terminated remote server name string
);
/*.....................................................................
Destructor:
.....................................................................*/
~Instance_Class(void); // the destructor
/*.....................................................................
Send data routine:
- sends an unsolicited packet of data to the remote server
.....................................................................*/
BOOL Poke_Server( LPBYTE, DWORD);
/*.....................................................................
Send data routine:
- sets up DNS for the server and registers a user callback to handle
incoming data
.....................................................................*/
BOOL Register_Server( BOOL CALLBACK (*)(LPBYTE, long));
/*.....................................................................
Does a trial connect to the remote server.
- used to determine whether server is alive or not (and thus running)
.....................................................................*/
BOOL Test_Server_Running( HSZ );
/*.....................................................................
Enables user callback (disabled by default)
.....................................................................*/
BOOL Enable_Callback( BOOL ); // enable or disable callback
/*.....................................................................
Open a connection for sending data to remote server
.....................................................................*/
BOOL Open_Poke_Connection( HSZ );
/*.....................................................................
Close connection with remote server
.....................................................................*/
BOOL Close_Poke_Connection( void );
//
// static members
//
/*.....................................................................
User callback - called upon receipt of incoming data (static member!)
.....................................................................*/
static BOOL CALLBACK (*callback) (
LPBYTE pointer, // pointer to received data
long length // if >0 length of received data
// if <0
// -1 == client connect detected
// -2 == client disconnect detected
);
/*.....................................................................
DDE callback, called when DDEML has an event for us
.....................................................................*/
static HDDEDATA CALLBACK dde_callback(
UINT uType, // transaction type
UINT uFmt, // clipboard data format
HCONV hconv, // handle of the conversation
HSZ hsz1, // handle of a string
HSZ hsz2, // handle of a string
HDDEDATA hdata, // handle of a global memory object
DWORD dwData1, // transaction-specific data
DWORD dwData2 // transaction-specific data
);
HANDLE instance; // this application's instance
HWND hwnd; // valid window handle
/*.....................................................................
member variables
.....................................................................*/
static DWORD id_inst; // instance identifier set by DdeInitialize
static BOOL process_pokes; // controls response to pokes
static char ascii_name[32]; // name of server
//
// non-static member variables
//
HSZ remote_name; // string handle for remote server name
HSZ local_name; // string handle for local server name
HSZ system_topic; // string handle for the "system" topic
HSZ poke_topic; // string handle for poking data to server topic
HSZ poke_item; // string handle for poking data to server item
HCONV conv_handle; // conversation handle
BOOL dde_error; // error flag
};
#endif