DDE.H 7.1 KB

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