DDE.H (7287B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /*************************************************************************** 17 ** 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 ** 18 *************************************************************************** 19 * * 20 * Project Name : Dynamic Data Encapsulation * 21 * * 22 * File Name : DDE.H * 23 * * 24 * Programmer : Steve Wetherill * 25 * * 26 * Start Date : June 1, 1996 * 27 * * 28 * Last Update : June 8, 1996 [SW] * 29 * * 30 *-------------------------------------------------------------------------* 31 * * 32 * This is the DDE (Instance_Class) which provides a simple CLIENT/SERVER * 33 * DDE model for data transactions between Windows applications. * 34 * This is a fairly naieve implementation allowing only one client/server * 35 * per Instance_Class object. * 36 * * 37 * Typical uses for this class are: * 38 * * 39 * i. Robust verification of whether an application is running * 40 * ii. Data transfer between applications * 41 * * 42 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 43 44 /* 45 ***************************** Class defines ***************************** 46 */ 47 48 #ifndef __DDE_H 49 #define __DDE_H 50 51 #define DDE_ADVISE_CONNECT -1 // advisory "client has connected" 52 #define DDE_ADVISE_DISCONNECT -2 // advisory "client has disconnected" 53 54 /* 55 ***************************** Class Declaration ***************************** 56 */ 57 58 class Instance_Class { 59 60 /* 61 ---------------------------- Public Interface ---------------------------- 62 */ 63 public: 64 65 /*..................................................................... 66 Constructor: 67 - takes null terminated ASCII strings names for client and server 68 .....................................................................*/ 69 70 Instance_Class( // constructor 71 LPSTR, // null terminated local sever name string 72 LPSTR // null terminated remote server name string 73 ); 74 75 /*..................................................................... 76 Destructor: 77 .....................................................................*/ 78 ~Instance_Class(void); // the destructor 79 80 /*..................................................................... 81 Send data routine: 82 - sends an unsolicited packet of data to the remote server 83 .....................................................................*/ 84 BOOL Poke_Server( LPBYTE, DWORD); 85 86 /*..................................................................... 87 Send data routine: 88 - sets up DNS for the server and registers a user callback to handle 89 incoming data 90 .....................................................................*/ 91 BOOL Register_Server( BOOL (CALLBACK *)(LPBYTE, long)); 92 93 /*..................................................................... 94 Does a trial connect to the remote server. 95 - used to determine whether server is alive or not (and thus running) 96 .....................................................................*/ 97 BOOL Test_Server_Running( HSZ ); 98 99 /*..................................................................... 100 Enables user callback (disabled by default) 101 .....................................................................*/ 102 BOOL Enable_Callback( BOOL ); // enable or disable callback 103 104 /*..................................................................... 105 Open a connection for sending data to remote server 106 .....................................................................*/ 107 BOOL Open_Poke_Connection( HSZ ); 108 109 /*..................................................................... 110 Close connection with remote server 111 .....................................................................*/ 112 BOOL Close_Poke_Connection( void ); 113 114 // 115 // static members 116 // 117 118 /*..................................................................... 119 User callback - called upon receipt of incoming data (static member!) 120 .....................................................................*/ 121 static BOOL (CALLBACK *callback) ( 122 123 LPBYTE pointer, // pointer to received data 124 long length // if >0 length of received data 125 // if <0 126 // -1 == client connect detected 127 // -2 == client disconnect detected 128 ); 129 130 /*..................................................................... 131 DDE callback, called when DDEML has an event for us 132 .....................................................................*/ 133 static HDDEDATA CALLBACK dde_callback( 134 135 UINT uType, // transaction type 136 UINT uFmt, // clipboard data format 137 HCONV hconv, // handle of the conversation 138 HSZ hsz1, // handle of a string 139 HSZ hsz2, // handle of a string 140 HDDEDATA hdata, // handle of a global memory object 141 DWORD dwData1, // transaction-specific data 142 DWORD dwData2 // transaction-specific data 143 ); 144 HANDLE instance; // this application's instance 145 HWND hwnd; // valid window handle 146 147 /*..................................................................... 148 member variables 149 .....................................................................*/ 150 151 static DWORD id_inst; // instance identifier set by DdeInitialize 152 static BOOL process_pokes; // controls response to pokes 153 static char ascii_name[32]; // name of server 154 155 // 156 // non-static member variables 157 // 158 159 HSZ remote_name; // string handle for remote server name 160 HSZ local_name; // string handle for local server name 161 HSZ system_topic; // string handle for the "system" topic 162 HSZ poke_topic; // string handle for poking data to server topic 163 HSZ poke_item; // string handle for poking data to server item 164 165 HCONV conv_handle; // conversation handle 166 BOOL dde_error; // error flag 167 168 }; 169 170 #endif 171 172