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