DDE.H 7.0 KB

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