home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / DPLAY.H < prev    next >
C/C++ Source or Header  |  1997-01-16  |  11KB  |  309 lines

  1. /*==========================================================================;
  2.  *
  3.  *  Copyright (C) 1994-1995 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:       dplay.h
  6.  *  Content:    DirectPlay include file
  7.  *
  8.  ***************************************************************************/
  9.  
  10. #ifndef __DPLAY_INCLUDED__
  11. #define __DPLAY_INCLUDED__
  12. #ifdef _WIN32
  13. /* for DECLARE_INTERFACE and HRESULT. */
  14. #include <ole2.h>
  15. #endif
  16.  
  17. #define _FACDP  0x877
  18. #define MAKE_DPHRESULT( code )    MAKE_HRESULT( 1, _FACDP, code )
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24. #pragma pack(push, 1)
  25.  
  26.  
  27. /*============================================================================
  28.  *
  29.  * DirectPlay Structures
  30.  *
  31.  * Various structures used to invoke DirectPlay.
  32.  *
  33.  *==========================================================================*/
  34.  
  35. #ifdef __cplusplus
  36. /* 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined */
  37. struct IDirectPlay;
  38. typedef struct IDirectPlay        FAR *LPDIRECTPLAY;
  39. #else                  
  40. typedef struct IDirectPlay        FAR *LPDIRECTPLAY;
  41. #endif
  42.  
  43. typedef DWORD DPID, FAR *LPDPID;
  44.  
  45. typedef struct _DPCAPS
  46. {
  47.     DWORD   dwSize;
  48.     DWORD   dwFlags;
  49.     DWORD   dwMaxBufferSize;
  50.     DWORD   dwMaxQueueSize;             // Function of DPlay, not SP.
  51.     DWORD   dwMaxPlayers;
  52.     DWORD   dwHundredBaud;              // 24 is 2400, 96 is 9600, etc.
  53.     DWORD   dwLatency;
  54. } DPCAPS;
  55.  
  56. typedef DPCAPS        FAR *LPDPCAPS;
  57.  
  58. #define DPLONGNAMELEN           52
  59. #define DPSHORTNAMELEN          20
  60. #define DPSESSIONNAMELEN        32
  61. #define DPPASSWORDLEN           16
  62. #define DPUSERRESERVED          16
  63.  
  64. typedef struct
  65. {
  66.     DWORD   dwSize;
  67.     GUID    guidSession;                  // Id for Game.  Null is all games.
  68.     DWORD   dwSession;                    // session identifier
  69.     DWORD   dwMaxPlayers;                 // Maximum players allowed in game.
  70.     DWORD   dwCurrentPlayers;             // Current  players in Game.
  71.     DWORD   dwFlags;                      // DPOPEN_* flags
  72.     char    szSessionName[DPSESSIONNAMELEN];// Human readable name for Game
  73.     char    szUserField[DPUSERRESERVED];
  74.     DWORD   dwReserved1;                  // Reserved for future MS use.
  75.     char    szPassword[DPPASSWORDLEN];    // Password to be allowed into game.
  76.     DWORD   dwReserved2;                  // Reserved for future MS use. 
  77.     DWORD   dwUser1;
  78.     DWORD   dwUser2;
  79.     DWORD   dwUser3;
  80.     DWORD   dwUser4;
  81. } DPSESSIONDESC;
  82. typedef DPSESSIONDESC FAR *LPDPSESSIONDESC;
  83.  
  84.  
  85. /*
  86.  * Create API
  87.  */
  88. typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACK)(
  89.     LPGUID              lpSPGuid,
  90.     LPSTR               lpFriendlyName,
  91.     DWORD               dwMajorVersion,
  92.     DWORD               dwMinorVersion,
  93.     LPVOID              lpContext);
  94.  
  95. typedef BOOL (FAR PASCAL * LPDPENUMSESSIONSCALLBACK)(
  96.     LPDPSESSIONDESC     lpDPSGameDesc,
  97.     LPVOID              lpContext,
  98.     LPDWORD             lpdwTimeOut,
  99.     DWORD               dwFlags);
  100.  
  101.  
  102.  
  103. extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY FAR *lplpDP, IUnknown FAR *pUnk);
  104. extern HRESULT WINAPI DirectPlayEnumerate( LPDPENUMDPCALLBACK, LPVOID );
  105.  
  106.  
  107. /* Player enumeration callback prototype */
  108. typedef BOOL (FAR PASCAL *LPDPENUMPLAYERSCALLBACK)(
  109.     DPID    dpId,
  110.     LPSTR   lpFriendlyName,
  111.     LPSTR   lpFormalName,
  112.     DWORD   dwFlags,
  113.     LPVOID  lpContext );
  114.  
  115. /*
  116.  * IDirectPlay
  117.  */
  118. #undef INTERFACE
  119. #define INTERFACE IDirectPlay
  120. #ifdef _WIN32
  121. DECLARE_INTERFACE_( IDirectPlay, IUnknown )
  122. {
  123.     /*** IUnknown methods ***/
  124.     STDMETHOD(QueryInterface)       (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  125.     STDMETHOD_(ULONG,AddRef)        (THIS)  PURE;
  126.     STDMETHOD_(ULONG,Release)       (THIS) PURE;
  127.     /*** IDirectPlay methods ***/
  128.     STDMETHOD(AddPlayerToGroup)     (THIS_ DPID, DPID) PURE;
  129.     STDMETHOD(Close)                (THIS) PURE;
  130.     STDMETHOD(CreatePlayer)         (THIS_ LPDPID,LPSTR,LPSTR,LPHANDLE) PURE;
  131.     STDMETHOD(CreateGroup)          (THIS_ LPDPID,LPSTR,LPSTR) PURE;
  132.     STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE;
  133.     STDMETHOD(DestroyPlayer)        (THIS_ DPID) PURE;
  134.     STDMETHOD(DestroyGroup)         (THIS_ DPID) PURE;
  135.     STDMETHOD(EnableNewPlayers)     (THIS_ BOOL) PURE;
  136.     STDMETHOD(EnumGroupPlayers)     (THIS_ DPID, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
  137.     STDMETHOD(EnumGroups)           (THIS_ DWORD, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
  138.     STDMETHOD(EnumPlayers)          (THIS_ DWORD, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
  139.     STDMETHOD(EnumSessions)         (THIS_ LPDPSESSIONDESC,DWORD,LPDPENUMSESSIONSCALLBACK,LPVOID,DWORD) PURE;
  140.     STDMETHOD(GetCaps)              (THIS_ LPDPCAPS) PURE;
  141.     STDMETHOD(GetMessageCount)      (THIS_ DPID, LPDWORD) PURE;
  142.     STDMETHOD(GetPlayerCaps)        (THIS_ DPID, LPDPCAPS) PURE;
  143.     STDMETHOD(GetPlayerName)        (THIS_ DPID,LPSTR,LPDWORD,LPSTR,LPDWORD) PURE;
  144.     STDMETHOD(Initialize)           (THIS_ LPGUID) PURE;
  145.     STDMETHOD(Open)                 (THIS_ LPDPSESSIONDESC) PURE;
  146.     STDMETHOD(Receive)              (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE;
  147.     STDMETHOD(SaveSession)          (THIS_ LPSTR) PURE;
  148.     STDMETHOD(Send)                 (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE;
  149.     STDMETHOD(SetPlayerName)        (THIS_ DPID,LPSTR,LPSTR) PURE;
  150. };
  151. #endif
  152.  
  153.  
  154.  
  155.  
  156. /****************************************************************************
  157.  *
  158.  * DIRECTPLAY ERRORS
  159.  *
  160.  * Errors are represented by negative values and cannot be combined.
  161.  *
  162.  ****************************************************************************/
  163. #define DP_OK                           0
  164. #define DPERR_ALREADYINITIALIZED        MAKE_DPHRESULT(   5 )
  165. #define DPERR_ACCESSDENIED              MAKE_DPHRESULT(  10 )
  166. #define DPERR_ACTIVEPLAYERS             MAKE_DPHRESULT(  20 )
  167. #define DPERR_BUFFERTOOSMALL            MAKE_DPHRESULT(  30 )
  168. #define DPERR_CANTADDPLAYER             MAKE_DPHRESULT(  40 )
  169. #define DPERR_CANTCREATEGROUP           MAKE_DPHRESULT(  50 )
  170. #define DPERR_CANTCREATEPLAYER          MAKE_DPHRESULT(  60 )
  171. #define DPERR_CANTCREATESESSION         MAKE_DPHRESULT(  70 )
  172. #define DPERR_CAPSNOTAVAILABLEYET       MAKE_DPHRESULT(  80 )
  173. #define DPERR_EXCEPTION                 MAKE_DPHRESULT(  90 )
  174. #define DPERR_GENERIC                   E_FAIL
  175.  
  176. #define DPERR_INVALIDFLAGS              MAKE_DPHRESULT( 120 )
  177. #define DPERR_INVALIDOBJECT             MAKE_DPHRESULT( 130 )
  178. #define DPERR_INVALIDPARAM              E_INVALIDARG
  179. #define DPERR_INVALIDPARAMS             DPERR_INVALIDPARAM
  180. #define DPERR_INVALIDPLAYER             MAKE_DPHRESULT( 150 )
  181. #define DPERR_NOCAPS                    MAKE_DPHRESULT( 160 )
  182. #define DPERR_NOCONNECTION              MAKE_DPHRESULT( 170 )
  183. #define DPERR_NOMEMORY                  E_OUTOFMEMORY
  184. #define DPERR_OUTOFMEMORY               DPERR_NOMEMORY
  185. #define DPERR_NOMESSAGES                MAKE_DPHRESULT( 190 )
  186. #define DPERR_NONAMESERVERFOUND         MAKE_DPHRESULT( 200 )
  187. #define DPERR_NOPLAYERS                 MAKE_DPHRESULT( 210 )
  188. #define DPERR_NOSESSIONS                MAKE_DPHRESULT( 220 )
  189. #define DPERR_SENDTOOBIG                MAKE_DPHRESULT( 230 )
  190. #define DPERR_TIMEOUT                   MAKE_DPHRESULT( 240 )
  191. #define DPERR_UNAVAILABLE               MAKE_DPHRESULT( 250 )
  192. #define DPERR_UNSUPPORTED               E_NOTIMPL
  193. #define DPERR_BUSY                      MAKE_DPHRESULT( 270 )
  194. #define DPERR_USERCANCEL                MAKE_DPHRESULT( 280 ) 
  195.  
  196.  
  197. #define DPOPEN_OPENSESSION          0x00000001
  198. #define DPOPEN_CREATESESSION        0x00000002
  199.  
  200. #define DPSEND_GUARANTEE            0x00000001
  201. #define DPSEND_HIGHPRIORITY         0x00000002
  202. #define DPSEND_TRYONCE              0x00000004
  203.  
  204. #define DPRECEIVE_ALL               0x00000001
  205. #define DPRECEIVE_TOPLAYER          0x00000002
  206. #define DPRECEIVE_FROMPLAYER        0x00000004
  207. #define DPRECEIVE_PEEK              0x00000008
  208.  
  209. #define DPCAPS_NAMESERVICE          0x00000001 // A name server is supported.
  210. #define DPCAPS_NAMESERVER           0x00000002 // You are the name server.
  211. #define DPCAPS_GUARANTEED           0x00000004 // SP's don't have to implement guarantees.
  212.  
  213. #define DPENUMSESSIONS_AVAILABLE    0x00000001 // All games that match password (if given)
  214.                                                // and have openings.
  215. #define DPENUMSESSIONS_ALL          0x00000002
  216. #define DPENUMSESSIONS_PREVIOUS     0x00000004
  217.  
  218. #define DPENUMPLAYERS_ALL           0x00000000
  219. #define DPENUMPLAYERS_PREVIOUS      0x00000004
  220. #define DPENUMPLAYERS_LOCAL         0x00000008
  221. #define DPENUMPLAYERS_REMOTE        0x00000010
  222. #define DPENUMPLAYERS_GROUP         0x00000020
  223. #define DPENUMPLAYERS_SESSION       0x00000080
  224.  
  225. //
  226. // This flag is set on the enumsessions callback when the time out has occured.
  227. // This means that there is no session data for this callback.
  228. // If lpdwTimeOut is set to a non-zero value and the EnumSessionsCallback returns
  229. // TRUE then EnumSessions will continue until the next timeout occurs.
  230. // Timeouts are in milliseconds.
  231.  
  232. #define DPESC_TIMEDOUT              0x00000001
  233.  
  234.  
  235. //
  236. // System message structures and types.
  237. //
  238. // System messages have a leading 4 byte type code to identify the message.
  239. // an app knows it is a system message because it is addressed 'To' player 0.
  240. //
  241.  
  242.                                     
  243. #define DPSYS_ADDPLAYER               0x0003  // DPMSG_ADDPLAYER
  244. #define DPSYS_DELETEPLAYER            0x0005  // DPMSG_DELETEPLAYER
  245.  
  246. #define DPSYS_ADDPLAYERTOGROUP        0x0007  // DPMSG_GROUPADD
  247.  
  248. #define DPSYS_INVITE                  0x000e  // DPMSG_INVITE, Net only.
  249.  
  250. #define DPSYS_DELETEGROUP             0x0020  // DPMSG_DELETEPLAYER
  251. #define DPSYS_DELETEPLAYERFROMGRP     0x0021  // DPMSG_GROUPDELETE
  252. #define DPSYS_SESSIONLOST             0x0031
  253.  
  254. #define DPSYS_CONNECT                 0x484b  // DPMSG_GENERIC
  255.  
  256.  
  257.  
  258. typedef struct
  259. {
  260.     DWORD       dwType;
  261.     DWORD       dwPlayerType;
  262.     DPID        dpId;
  263.     char        szLongName[DPLONGNAMELEN];
  264.     char        szShortName[DPSHORTNAMELEN];
  265.     DWORD       dwCurrentPlayers;
  266. }   DPMSG_ADDPLAYER;
  267.  
  268. typedef DPMSG_ADDPLAYER DPMSG_ADDGROUP;
  269.  
  270. typedef struct
  271. {
  272.     DWORD       dwType;
  273.     DPID        dpIdGroup;
  274.     DPID        dpIdPlayer;
  275. } DPMSG_GROUPADD;
  276.  
  277. typedef DPMSG_GROUPADD DPMSG_GROUPDELETE;
  278. typedef struct
  279. {
  280.     DWORD       dwType;
  281.     DPID        dpId;
  282. } DPMSG_DELETEPLAYER;
  283.  
  284. typedef struct
  285. {
  286.     DWORD           dwType;
  287.     DPSESSIONDESC   dpsDesc;
  288. } DPMSG_INVITE;
  289.  
  290.  
  291.  
  292. typedef struct
  293. {
  294.     DWORD           dwType;
  295. } DPMSG_GENERIC;
  296.  
  297. #pragma pack(pop)
  298.  
  299.  
  300. DEFINE_GUID( IID_IDirectPlay, 0x5454e9a0, 0xdb65, 0x11ce, 0x92, 0x1c, 0x00, 0xaa, 0x00, 0x6c, 0x49, 0x72);
  301.  
  302.  
  303.  
  304. #ifdef __cplusplus
  305. };
  306. #endif
  307.  
  308. #endif
  309.