Subversion Repositories spacemission

Rev

Rev 10 | Rev 16 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. unit DirectPlay;
  2.  
  3. (*==========================================================================;
  4.  *
  5.  *  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  6.  *
  7.  *  File:       dplay.h dplobby.h
  8.  *  Content:    DirectPlay include files
  9.  *
  10.  *  DirectX 7 Delphi adaptation by Erik Unger
  11.  *
  12.  *  Modified: 4-Jun-2000
  13.  *
  14.  *  Download: http://www.delphi-jedi.org/DelphiGraphics/
  15.  *  E-Mail: DelphiDirectX@next-reality.com
  16.  *
  17.  ***************************************************************************)
  18.  
  19. interface
  20.  
  21. {$INCLUDE DelphiXcfg.inc}
  22.  
  23. {$IFNDEF UseDirectPlay} // Daniel Marschall 12.04.2024 Added to avoid Windows showing "This app requires DirectPlay"
  24. {$MESSAGE ERROR 'If you want to use DXPlay.pas, please enable the IFDEF UseDirectPlay in DelphiXcfg.inc'}
  25. {$ENDIF}
  26.  
  27. {$MINENUMSIZE 4}
  28. {$ALIGN ON}
  29.  
  30. uses
  31.   Windows;
  32.  
  33. var
  34.   DPlayDLL: HMODULE = 0;
  35.  
  36. (*==========================================================================;
  37.  *
  38.  *  Copyright (C) 1994-1997 Microsoft Corporation.  All Rights Reserved.
  39.  *
  40.  *  File:       dplay.h
  41.  *  Content:    DirectPlay include file
  42.  *
  43.  ***************************************************************************)
  44.  
  45. function DPErrorString(Value: HResult): string;
  46.  
  47. const
  48. // {D1EB6D20-8923-11d0-9D97-00A0C90A43CB}
  49.   CLSID_DirectPlay: TGUID =
  50.   (D1: $D1EB6D20; D2: $8923; D3: $11D0; D4: ($9D, $97, $00, $A0, $C9, $A, $43, $CB));
  51.  
  52. (*
  53.  * GUIDS used by Service Providers shipped with DirectPlay
  54.  * Use these to identify Service Provider returned by EnumConnections
  55.  *)
  56.  
  57. // GUID for IPX service provider
  58. // {685BC400-9D2C-11cf-A9CD-00AA006886E3}
  59.   DPSPGUID_IPX: TGUID =
  60.   (D1: $685BC400; D2: $9D2C; D3: $11CF; D4: ($A9, $CD, $00, $AA, $00, $68, $86, $E3));
  61.  
  62. // GUID for TCP/IP service provider
  63. // 36E95EE0-8577-11cf-960C-0080C7534E82
  64.   DPSPGUID_TCPIP: TGUID =
  65.   (D1: $36E95EE0; D2: $8577; D3: $11CF; D4: ($96, $0C, $00, $80, $C7, $53, $4E, $82));
  66.  
  67. // GUID for Serial service provider
  68. // {0F1D6860-88D9-11cf-9C4E-00A0C905425E}
  69.   DPSPGUID_SERIAL: TGUID =
  70.   (D1: $F1D6860; D2: $88D9; D3: $11CF; D4: ($9C, $4E, $00, $A0, $C9, $05, $42, $5E));
  71.  
  72. // GUID for Modem service provider
  73. // {44EAA760-CB68-11cf-9C4E-00A0C905425E}
  74.   DPSPGUID_MODEM: TGUID =
  75.   (D1: $44EAA760; D2: $CB68; D3: $11CF; D4: ($9C, $4E, $00, $A0, $C9, $05, $42, $5E));
  76.  
  77. (****************************************************************************
  78.  *
  79.  * DirectPlay Structures
  80.  *
  81.  * Various structures used to invoke DirectPlay.
  82.  *
  83.  ****************************************************************************)
  84.  
  85. type
  86. (*
  87.  * TDPID
  88.  * DirectPlay player and group ID
  89.  *)
  90.   TDPID = DWORD;
  91.   PDPID = ^TDPID;
  92.  
  93. const
  94. (*
  95.  * DPID that system messages come from
  96.  *)
  97.   DPID_SYSMSG = 0;
  98.  
  99. (*
  100.  * DPID representing all players in the session
  101.  *)
  102.   DPID_ALLPLAYERS = 0;
  103.  
  104. (*
  105.  * DPID representing the server player
  106.  *)
  107.   DPID_SERVERPLAYER = 1;
  108.  
  109. (*
  110.  * DPID representing the maximum ID in the range of DPID's reserved for
  111.  * use by DirectPlay.
  112.  *)
  113.   DPID_RESERVEDRANGE = 100;
  114.  
  115. (*
  116.  * The player ID is unknown (used with e.g. DPSESSION_NOMESSAGEID)
  117.  *)
  118.   DPID_UNKNOWN = $FFFFFFFF;
  119.  
  120. type
  121. (*
  122.  * DPCAPS
  123.  * Used to obtain the capabilities of a DirectPlay object
  124.  *)
  125.   PDPCaps = ^TDPCaps;
  126.   TDPCaps = packed record
  127.     dwSize: DWORD; // Size of structure, in bytes
  128.     dwFlags: DWORD; // DPCAPS_xxx flags
  129.     dwMaxBufferSize: DWORD; // Maximum message size, in bytes,  for this service provider
  130.     dwMaxQueueSize: DWORD; // Obsolete.
  131.     dwMaxPlayers: DWORD; // Maximum players/groups (local + remote)
  132.     dwHundredBaud: DWORD; // Bandwidth in 100 bits per second units;
  133.                                 // i.e. 24 is 2400, 96 is 9600, etc.
  134.     dwLatency: DWORD; // Estimated latency; 0 = unknown
  135.     dwMaxLocalPlayers: DWORD; // Maximum # of locally created players allowed
  136.     dwHeaderLength: DWORD; // Maximum header length, in bytes, on messages
  137.                                 // added by the service provider
  138.     dwTimeout: DWORD; // Service provider's suggested timeout value
  139.                                 // This is how long DirectPlay will wait for
  140.                                 // responses to system messages
  141.   end;
  142.  
  143. const
  144. (*
  145.  * This DirectPlay object is the session host.  If the host exits the
  146.  * session, another application will become the host and receive a
  147.  * DPSYS_HOST system message.
  148.  *)
  149.   DPCAPS_ISHOST = $00000002;
  150.  
  151. (*
  152.  * The service provider bound to this DirectPlay object can optimize
  153.  * group messaging.
  154.  *)
  155.   DPCAPS_GROUPOPTIMIZED = $00000008;
  156.  
  157. (*
  158.  * The service provider bound to this DirectPlay object can optimize
  159.  * keep alives (see DPSESSION_KEEPALIVE)
  160.  *)
  161.   DPCAPS_KEEPALIVEOPTIMIZED = $00000010;
  162.  
  163. (*
  164.  * The service provider bound to this DirectPlay object can optimize
  165.  * guaranteed message delivery.
  166.  *)
  167.   DPCAPS_GUARANTEEDOPTIMIZED = $00000020;
  168.  
  169. (*
  170.  * This DirectPlay object supports guaranteed message delivery.
  171.  *)
  172.   DPCAPS_GUARANTEEDSUPPORTED = $00000040;
  173.  
  174. (*
  175.  * This DirectPlay object supports digital signing of messages.
  176.  *)
  177.   DPCAPS_SIGNINGSUPPORTED = $00000080;
  178.  
  179. (*
  180.  * This DirectPlay object supports encryption of messages.
  181.  *)
  182.   DPCAPS_ENCRYPTIONSUPPORTED = $00000100;
  183.  
  184. (*
  185.  * This DirectPlay player was created on this machine
  186.  *)
  187.   DPPLAYERCAPS_LOCAL = $00000800;
  188.  
  189. (*
  190.  * Current Open settings supports all forms of Cancel
  191.  *)
  192.   DPCAPS_ASYNCCANCELSUPPORTED = $00001000;
  193.  
  194. (*
  195.  * Current Open settings supports CancelAll, but not Cancel
  196.  *)
  197.   DPCAPS_ASYNCCANCELALLSUPPORTED = $00002000;
  198.  
  199. (*
  200.  * Current Open settings supports Send Timeouts for sends
  201.  *)
  202.   DPCAPS_SENDTIMEOUTSUPPORTED = $00004000;
  203.  
  204. (*
  205.  * Current Open settings supports send priority
  206.  *)
  207.   DPCAPS_SENDPRIORITYSUPPORTED = $00008000;
  208.  
  209. (*
  210.  * Current Open settings supports DPSEND_ASYNC flag
  211.  *)
  212.   DPCAPS_ASYNCSUPPORTED = $00010000;
  213.  
  214. type
  215. (*
  216.  * TDPSessionDesc2
  217.  * Used to describe the properties of a DirectPlay
  218.  * session instance
  219.  *)
  220.   PDPSessionDesc2 = ^TDPSessionDesc2;
  221.   TDPSessionDesc2 = packed record
  222.     dwSize: DWORD; // Size of structure
  223.     dwFlags: DWORD; // DPSESSION_xxx flags
  224.     guidInstance: TGUID; // ID for the session instance
  225.     guidApplication: TGUID; // GUID of the DirectPlay application.
  226.                                // GUID_NULL for all applications.
  227.     dwMaxPlayers: DWORD; // Maximum # players allowed in session
  228.     dwCurrentPlayers: DWORD; // Current # players in session (read only)
  229.     case Integer of
  230.       0: (
  231.         lpszSessionName: PChar; // Name of the session
  232.         lpszPassword: PChar; // Password of the session (optional)
  233.         dwReserved1: DWORD; // Reserved for future MS use.
  234.         dwReserved2: DWORD;
  235.         dwUser1: DWORD; // For use by the application
  236.         dwUser2: DWORD;
  237.         dwUser3: DWORD;
  238.         dwUser4: DWORD;
  239.         );
  240.       1: (
  241.         lpszSessionNameA: PAnsiChar; // Name of the session
  242.         lpszPasswordA: PAnsiChar // Password of the session (optional)
  243.         );
  244.       2: (
  245.         lpszSessionNameW: PWideChar;
  246.         lpszPasswordW: PWideChar
  247.         );
  248.   end;
  249.  
  250. const
  251. (*
  252.  * Applications cannot create new players in this session.
  253.  *)
  254.   DPSESSION_NEWPLAYERSDISABLED = $00000001;
  255.  
  256. (*
  257.  * If the DirectPlay object that created the session, the host,
  258.  * quits, then the host will attempt to migrate to another
  259.  * DirectPlay object so that new players can continue to be created
  260.  * and new applications can join the session.
  261.  *)
  262.   DPSESSION_MIGRATEHOST = $00000004;
  263.  
  264. (*
  265.  * This flag tells DirectPlay not to set the idPlayerTo and idPlayerFrom
  266.  * fields in player messages.  This cuts two DWORD's off the message
  267.  * overhead.
  268.  *)
  269.   DPSESSION_NOMESSAGEID = $00000008;
  270.  
  271. (*
  272.  * This flag tells DirectPlay to not allow any new applications to
  273.  * join the session.  Applications already in the session can still
  274.  * create new players.
  275.  *)
  276.   DPSESSION_JOINDISABLED = $00000020;
  277.  
  278. (*
  279.  * This flag tells DirectPlay to detect when remote players
  280.  * exit abnormally (e.g. their computer or modem gets unplugged)
  281.  *)
  282.   DPSESSION_KEEPALIVE = $00000040;
  283.  
  284. (*
  285.  * This flag tells DirectPlay not to send a message to all players
  286.  * when a players remote data changes
  287.  *)
  288.   DPSESSION_NODATAMESSAGES = $00000080;
  289.  
  290. (*
  291.  * This flag indicates that the session belongs to a secure server
  292.  * and needs user authentication
  293.  *)
  294.   DPSESSION_SECURESERVER = $00000100;
  295.  
  296. (*
  297.  * This flag indicates that the session is private and requirs a password
  298.  * for EnumSessions as well as Open.
  299.  *)
  300.   DPSESSION_PRIVATE = $00000200;
  301.  
  302. (*
  303.  * This flag indicates that the session requires a password for joining.
  304.  *)
  305.   DPSESSION_PASSWORDREQUIRED = $00000400;
  306.  
  307. (*
  308.  * This flag tells DirectPlay to route all messages through the server
  309.  *)
  310.   DPSESSION_MULTICASTSERVER = $00000800;
  311.  
  312. (*
  313.  * This flag tells DirectPlay to only download information about the
  314.  * DPPLAYER_SERVERPLAYER.
  315.  *)
  316.   DPSESSION_CLIENTSERVER = $00001000;
  317.  
  318. (*
  319.  * This flag tells DirectPlay to use the protocol built into dplay
  320.  * for reliability and statistics all the time.  When this bit is
  321.  * set, only other sessions with this bit set can join or be joined.
  322.  *)
  323.   DPSESSION_DIRECTPLAYPROTOCOL = $00002000;
  324.  
  325. (*
  326.  * This flag tells DirectPlay that preserving order of received
  327.  * packets is not important, when using reliable delivery.  This
  328.  * will allow messages to be indicated out of order if preceding
  329.  * messages have not yet arrived.  Otherwise DPLAY will wait for
  330.  * earlier messages before delivering later reliable messages.
  331.  *)
  332.   DPSESSION_NOPRESERVEORDER = $00004000;
  333.  
  334. (*
  335.  * This flag tells DirectPlay to optimize communication for latency
  336.  *)
  337.   DPSESSION_OPTIMIZELATENCY = $00008000;
  338.  
  339. type
  340. (*
  341.  * TDPName
  342.  * Used to hold the name of a DirectPlay entity
  343.  * like a player or a group
  344.  *)
  345.   PDPName = ^TDPName;
  346.   TDPName = packed record
  347.     dwSize: DWORD; // Size of structure
  348.     dwFlags: DWORD; // Not used. Must be zero.
  349.     case Integer of
  350.       0: (
  351.         lpszShortName: PChar; // The short or friendly name
  352.         lpszLongName: PChar; // The long or formal name
  353.         );
  354.       1: (
  355.         lpszShortNameA: PAnsiChar;
  356.         lpszLongNameA: PAnsiChar;
  357.         );
  358.       2: (
  359.         lpszShortNameW: PWideChar;
  360.         lpszLongNameW: PWideChar;
  361.         );
  362.   end;
  363.  
  364. (*
  365.  * TDPCredentials
  366.  * Used to hold the user name and password of a DirectPlay user
  367.  *)
  368.  
  369.   PDPCredentials = ^TDPCredentials;
  370.   TDPCredentials = packed record
  371.     dwSize: DWORD; // Size of structure
  372.     dwFlags: DWORD; // Not used. Must be zero.
  373.     case Integer of
  374.       0: (
  375.         lpszUsername: PChar; // User name of the account
  376.         lpszPassword: PChar; // Password of the account
  377.         lpszDomain: PChar; // Domain name of the account
  378.         );
  379.       1: (
  380.         lpszUsernameA: PAnsiChar; // User name of the account
  381.         lpszPasswordA: PAnsiChar; // Password of the account
  382.         lpszDomainA: PAnsiChar; // Domain name of the account
  383.         );
  384.       2: (
  385.         lpszUsernameW: PWideChar; // User name of the account
  386.         lpszPasswordW: PWideChar; // Password of the account
  387.         lpszDomainW: PWideChar; // Domain name of the account
  388.         );
  389.   end;
  390.  
  391. (*
  392.  * TDPSecurityDesc
  393.  * Used to describe the security properties of a DirectPlay
  394.  * session instance
  395.  *)
  396.   PDPSecurityDesc = ^TDPSecurityDesc;
  397.   TDPSecurityDesc = packed record
  398.     dwSize: DWORD; // Size of structure
  399.     dwFlags: DWORD; // Not used. Must be zero.
  400.     case Integer of
  401.       0: (
  402.         lpszSSPIProvider: PChar; // SSPI provider name
  403.         lpszCAPIProvider: PChar; // CAPI provider name
  404.         dwCAPIProviderType: DWORD; // Crypto Service Provider type
  405.         dwEncryptionAlgorithm: DWORD; // Encryption Algorithm type
  406.         );
  407.       1: (
  408.         lpszSSPIProviderA: PAnsiChar; // SSPI provider name
  409.         lpszCAPIProviderA: PAnsiChar; // CAPI provider name
  410.         );
  411.       2: (
  412.         lpszSSPIProviderW: PWideChar; // SSPI provider name
  413.         lpszCAPIProviderW: PWideChar; // CAPI provider name
  414.         );
  415.   end;
  416.  
  417. (*
  418.  * DPACCOUNTDESC
  419.  * Used to describe a user membership account
  420.  *)
  421.  
  422.   PDPAccountDesc = ^TDPAccountDesc;
  423.   TDPAccountDesc = packed record
  424.     dwSize: DWORD; // Size of structure
  425.     dwFlags: DWORD; // Not used. Must be zero.
  426.     case Integer of
  427.       0: (lpszAccountID: PChar); // Account identifier
  428.       1: (lpszAccountIDA: PAnsiChar);
  429.       2: (lpszAccountIDW: PWideChar);
  430.   end;
  431.  
  432. (*
  433.  * TDPLConnection
  434.  * Used to hold all in the informaion needed to connect
  435.  * an application to a session or create a session
  436.  *)
  437.   PDPLConnection = ^TDPLConnection;
  438.   TDPLConnection = packed record
  439.     dwSize: DWORD; // Size of this structure
  440.     dwFlags: DWORD; // Flags specific to this structure
  441.     lpSessionDesc: PDPSessionDesc2; // Pointer to session desc to use on connect
  442.     lpPlayerName: PDPName; // Pointer to Player name structure
  443.     guidSP: TGUID; // GUID of the DPlay SP to use
  444.     lpAddress: Pointer; // Address for service provider
  445.     dwAddressSize: DWORD; // Size of address data
  446.   end;
  447.  
  448. (*
  449.  * TDPChat
  450.  * Used to hold the a DirectPlay chat message
  451.  *)
  452.   PDPChat = ^TDPChat;
  453.   TDPChat = packed record
  454.     dwSize: DWORD;
  455.     dwFlags: DWORD;
  456.     case Integer of
  457.       0: (lpszMessage: PChar); // Message string
  458.       1: (lpszMessageA: PAnsiChar);
  459.       2: (lpszMessageW: PWideChar);
  460.   end;
  461.  
  462. (*
  463.  * TSGBuffer
  464.  * Scatter Gather Buffer used for SendEx
  465.  *)
  466.   PSGBuffer = ^TSGBuffer;
  467.   TSGBuffer = packed record
  468.     len: UINT;
  469.     pData: PUCHAR;
  470.   end;
  471.  
  472. (****************************************************************************
  473.  *
  474.  * Prototypes for DirectPlay callback functions
  475.  *
  476.  ****************************************************************************)
  477.  
  478. (*
  479.  * Callback for IDirectPlay2::EnumSessions
  480.  *)
  481.   TDPEnumSessionsCallback2 = function(lpThisSD: PDPSessionDesc2;
  482.     var lpdwTimeOut: DWORD; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall;
  483.  
  484. const
  485. (*
  486.  * This flag is set on the EnumSessions callback dwFlags parameter when
  487.  * the time out has occurred. There will be no session data for this
  488.  * callback. If *lpdwTimeOut is set to a non-zero value and the
  489.  * EnumSessionsCallback function returns TRUE then EnumSessions will
  490.  * continue waiting until the next timeout occurs. Timeouts are in
  491.  * milliseconds.
  492.  *)
  493.   DPESC_TIMEDOUT = $00000001;
  494.  
  495. type
  496. (*
  497.  * Callback for IDirectPlay2.EnumPlayers
  498.  *              IDirectPlay2.EnumGroups
  499.  *              IDirectPlay2.EnumGroupPlayers
  500.  *)
  501.   TDPEnumPlayersCallback2 = function(DPID: TDPID; dwPlayerType: DWORD;
  502.     const lpName: TDPName; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall;
  503.  
  504. (*
  505.  * ANSI callback for DirectPlayEnumerate
  506.  * This callback prototype will be used if compiling
  507.  * for ANSI strings
  508.  *)
  509.   TDPEnumDPCallbackA = function(const lpguidSP: TGUID; lpSPName: PAnsiChar;
  510.     dwMajorVersion: DWORD; dwMinorVersion: DWORD; lpContext: Pointer): BOOL; stdcall;
  511.  
  512. (*
  513.  * Unicode callback for DirectPlayEnumerate
  514.  * This callback prototype will be used if compiling
  515.  * for Unicode strings
  516.  *)
  517.   TDPEnumDPCallbackW = function(const lpguidSP: TGUID; lpSPName: PWideChar;
  518.     dwMajorVersion: DWORD; dwMinorVersion: DWORD; lpContext: Pointer): BOOL; stdcall;
  519.  
  520. (*
  521.  * Callback for DirectPlayEnumerate
  522.  *)
  523. {$IFDEF UNICODE}
  524.   TDPEnumDPCallback = TDPEnumDPCallbackW;
  525. {$ELSE}
  526.   TDPEnumDPCallback = TDPEnumDPCallbackA;
  527. {$ENDIF}
  528.  
  529. (*
  530.  * Callback for IDirectPlay3(A/W).EnumConnections
  531.  *)
  532.   TDPEnumConnectionsCallback = function(const lpguidSP: TGUID;
  533.     lpConnection: Pointer; dwConnectionSize: DWORD; const lpName: TDPName;
  534.     dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall;
  535.  
  536. (*
  537.  * API's
  538.  *)
  539.  
  540. var
  541.   DirectPlayEnumerate: function(lpEnumDPCallback: TDPEnumDPCallback;
  542.     lpContext: Pointer): HResult; stdcall;
  543.   DirectPlayEnumerateA: function(lpEnumDPCallback: TDPEnumDPCallbackA;
  544.     lpContext: Pointer): HResult; stdcall;
  545.   DirectPlayEnumerateW: function(lpEnumDPCallback: TDPEnumDPCallbackW;
  546.     lpContext: Pointer): HResult; stdcall;
  547.  
  548. (****************************************************************************
  549.  *
  550.  * IDirectPlay2 (and IDirectPlay2A) Interface
  551.  *
  552.  ****************************************************************************)
  553.  
  554. type
  555.   IDirectPlay2AW = interface(IUnknown)
  556.     (*** IDirectPlay2 methods ***)
  557.     function AddPlayerToGroup(idGroup: TDPID; idPlayer: TDPID): HResult; stdcall;
  558.     function Close: HResult; stdcall;
  559.     function CreateGroup(out lpidGroup: TDPID; lpGroupName: PDPName;
  560.       lpData: Pointer; dwDataSize: DWORD; dwFlags: DWORD): HResult; stdcall;
  561.     function CreatePlayer(out lpidPlayer: TDPID; pPlayerName: PDPName;
  562.       hEvent: THandle; lpData: Pointer; dwDataSize: DWORD; dwFlags: DWORD): HResult; stdcall;
  563.     function DeletePlayerFromGroup(idGroup: TDPID; idPlayer: TDPID): HResult; stdcall;
  564.     function DestroyGroup(idGroup: TDPID): HResult; stdcall;
  565.     function DestroyPlayer(idPlayer: TDPID): HResult; stdcall;
  566.     function EnumGroupPlayers(idGroup: TDPID; lpguidInstance: PGUID;
  567.       lpEnumPlayersCallback2: TDPEnumPlayersCallback2; lpContext: Pointer;
  568.       dwFlags: DWORD): HResult; stdcall;
  569.     function EnumGroups(lpguidInstance: PGUID; lpEnumPlayersCallback2:
  570.       TDPEnumPlayersCallback2; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
  571.     function EnumPlayers(lpguidInstance: PGUID; lpEnumPlayersCallback2:
  572.       TDPEnumPlayersCallback2; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
  573.     function EnumSessions(const lpsd: TDPSessionDesc2; dwTimeout: DWORD;
  574.       lpEnumSessionsCallback2: TDPEnumSessionsCallback2; lpContext: Pointer;
  575.       dwFlags: DWORD): HResult; stdcall;
  576.     function GetCaps(var lpDPCaps: TDPCaps; dwFlags: DWORD): HResult; stdcall;
  577.     function GetGroupData(idGroup: TDPID; lpData: Pointer; var lpdwDataSize: DWORD;
  578.       dwFlags: DWORD): HResult; stdcall;
  579.     function GetGroupName(idGroup: TDPID; lpData: Pointer; var lpdwDataSize: DWORD):
  580.       HResult; stdcall;
  581.     function GetMessageCount(idPlayer: TDPID; var lpdwCount: DWORD): HResult; stdcall;
  582.     function GetPlayerAddress(idPlayer: TDPID; lpAddress: Pointer;
  583.       var lpdwAddressSize: DWORD): HResult; stdcall;
  584.     function GetPlayerCaps(idPlayer: TDPID; var lpPlayerCaps: TDPCaps;
  585.       dwFlags: DWORD): HResult; stdcall;
  586.     function GetPlayerData(idPlayer: TDPID; lpData: Pointer; var lpdwDataSize: DWORD;
  587.       dwFlags: DWORD): HResult; stdcall;
  588.     function GetPlayerName(idPlayer: TDPID; lpData: Pointer; var lpdwDataSize: DWORD): HResult; stdcall;
  589.     function GetSessionDesc(lpData: Pointer; var lpdwDataSize: DWORD): HResult; stdcall;
  590.     function Initialize(const lpGUID: TGUID): HResult; stdcall;
  591.     function Open(var lpsd: TDPSessionDesc2; dwFlags: DWORD): HResult; stdcall;
  592.     function Receive(var lpidFrom: TDPID; var lpidTo: TDPID; dwFlags: DWORD;
  593.       lpData: Pointer; var lpdwDataSize: DWORD): HResult; stdcall;
  594.     function Send(idFrom: TDPID; lpidTo: TDPID; dwFlags: DWORD; var lpData;
  595.       lpdwDataSize: DWORD): HResult; stdcall;
  596.     function SetGroupData(idGroup: TDPID; lpData: Pointer; dwDataSize: DWORD;
  597.       dwFlags: DWORD): HResult; stdcall;
  598.     function SetGroupName(idGroup: TDPID; lpGroupName: PDPName;
  599.       dwFlags: DWORD): HResult; stdcall;
  600.     function SetPlayerData(idPlayer: TDPID; lpData: Pointer; dwDataSize: DWORD;
  601.       dwFlags: DWORD): HResult; stdcall;
  602.     function SetPlayerName(idPlayer: TDPID; lpPlayerName: PDPName;
  603.       dwFlags: DWORD): HResult; stdcall;
  604.     function SetSessionDesc(var lpSessDesc: TDPSessionDesc2; dwFlags: DWORD):
  605.       HResult; stdcall;
  606.   end;
  607.  
  608.   IDirectPlay2W = interface(IDirectPlay2AW)
  609.     ['{2B74F7C0-9154-11CF-A9CD-00AA006886E3}']
  610.   end;
  611.   IDirectPlay2A = interface(IDirectPlay2AW)
  612.     ['{9d460580-a822-11cf-960c-0080c7534e82}']
  613.   end;
  614.  
  615. {$IFDEF UNICODE}
  616.   IDirectPlay2 = IDirectPlay2W;
  617. {$ELSE}
  618.   IDirectPlay2 = IDirectPlay2A;
  619. {$ENDIF}
  620.  
  621. (****************************************************************************
  622.  *
  623.  * IDirectPlay3 (and IDirectPlay3A) Interface
  624.  *
  625.  ****************************************************************************)
  626.  
  627.   IDirectPlay3AW = interface(IDirectPlay2AW)
  628.     (*** IDirectPlay3 methods ***)
  629.     function AddGroupToGroup(idParentGroup: TDPID; idGroup: TDPID): HResult; stdcall;
  630.     function CreateGroupInGroup(idParentGroup: TDPID; var lpidGroup: TDPID;
  631.       lpGroupName: PDPName; lpData: Pointer; dwDataSize: DWORD;
  632.       dwFlags: DWORD): HResult; stdcall;
  633.     function DeleteGroupFromGroup(idParentGroup: TDPID; idGroup: TDPID): HResult; stdcall;
  634.     function EnumConnections(lpguidApplication: PGUID;
  635.       lpEnumCallback: TDPEnumConnectionsCallback; lpContext: Pointer;
  636.       dwFlags: DWORD): HResult; stdcall;
  637.     function EnumGroupsInGroup(idGroup: TDPID; lpguidInstance: PGUID;
  638.       lpEnumPlayersCallback2: TDPEnumPlayersCallback2; lpContext: Pointer;
  639.       dwFlags: DWORD): HResult; stdcall;
  640.     function GetGroupConnectionSettings(dwFlags: DWORD; idGroup: TDPID;
  641.       lpData: Pointer; var lpdwDataSize: DWORD): HResult; stdcall;
  642.     function InitializeConnection(lpConnection: Pointer; dwFlags: DWORD): HResult; stdcall;
  643.     function SecureOpen(var lpsd: TDPSessionDesc2; dwFlags: DWORD;
  644.       var lpSecurity: TDPSecurityDesc; var lpCredentials: TDPCredentials): HResult; stdcall;
  645.     function SendChatMessage(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD;
  646.       var lpChatMessage: TDPChat): HResult; stdcall;
  647.     function SetGroupConnectionSettings(dwFlags: DWORD; idGroup: TDPID;
  648.       var lpConnection: TDPLConnection): HResult; stdcall;
  649.     function StartSession(dwFlags: DWORD; idGroup: TDPID): HResult; stdcall;
  650.     function GetGroupFlags(idGroup: TDPID; out lpdwFlags: DWORD): HResult; stdcall;
  651.     function GetGroupParent(idGroup: TDPID; out lpidParent: TDPID): HResult; stdcall;
  652.     function GetPlayerAccount(idPlayer: TDPID; dwFlags: DWORD; var lpData;
  653.       var lpdwDataSize: DWORD): HResult; stdcall;
  654.     function GetPlayerFlags(idPlayer: TDPID; out lpdwFlags: DWORD): HResult; stdcall;
  655.   end;
  656.  
  657.   IDirectPlay3W = interface(IDirectPlay3AW)
  658.     ['{133EFE40-32DC-11D0-9CFB-00A0C90A43CB}']
  659.   end;
  660.   IDirectPlay3A = interface(IDirectPlay3AW)
  661.     ['{133efe41-32dc-11d0-9cfb-00a0c90a43cb}']
  662.   end;
  663.  
  664. {$IFDEF UNICODE}
  665.   IDirectPlay3 = IDirectPlay3W;
  666. {$ELSE}
  667.   IDirectPlay3 = IDirectPlay3A;
  668. {$ENDIF}
  669.  
  670. (****************************************************************************
  671.  *
  672.  * IDirectPlay4 (and IDirectPlay4A) Interface
  673.  *
  674.  ****************************************************************************)
  675.  
  676.   IDirectPlay4AW = interface(IDirectPlay3AW)
  677.     (*** IDirectPlay4 methods ***)
  678.     function GetGroupOwner(idGroup: TDPID; out idOwner: TDPID): HResult; stdcall;
  679.     function SetGroupOwner(idGroup: TDPID; idOwner: TDPID): HResult; stdcall;
  680.     function SendEx(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD; lpData: Pointer;
  681.       dwDataSize: DWORD; dwPriority: DWORD; dwTimeout: DWORD;
  682.       lpContext: Pointer; lpdwMsgId: PDWORD): HResult; stdcall;
  683.     function GetMessageQueue(idFrom: TDPID; idTo: TDPID; dwFlags: DWORD;
  684.       lpdwNumMsgs: PDWORD; lpdwNumBytes: PDWORD): HResult; stdcall;
  685.     function CancelMessage(dwMessageID: DWORD; dwFlags: DWORD): HResult; stdcall;
  686.     function CancelPriority(dwMinPriority: DWORD; dwMaxPriority: DWORD; dwFlags: DWORD): HResult; stdcall;
  687.   end;
  688.  
  689.   IDirectPlay4W = interface(IDirectPlay4AW)
  690.     ['{0ab1c530-4745-11D1-a7a1-0000f803abfc}']
  691.   end;
  692.   IDirectPlay4A = interface(IDirectPlay4AW)
  693.     ['{0ab1c531-4745-11D1-a7a1-0000f803abfc}']
  694.   end;
  695.  
  696. {$IFDEF UNICODE}
  697.   IDirectPlay4 = IDirectPlay4W;
  698. {$ELSE}
  699.   IDirectPlay4 = IDirectPlay4A;
  700. {$ENDIF}
  701.  
  702. const
  703. (****************************************************************************
  704.  *
  705.  * EnumConnections API flags
  706.  *
  707.  ****************************************************************************)
  708.  
  709. (*
  710.  * Enumerate Service Providers
  711.  *)
  712.   DPCONNECTION_DIRECTPLAY = $00000001;
  713.  
  714. (*
  715.  * Enumerate Lobby Providers
  716.  *)
  717.   DPCONNECTION_DIRECTPLAYLOBBY = $00000002;
  718.  
  719. (****************************************************************************
  720.  *
  721.  * EnumPlayers API flags
  722.  *
  723.  ****************************************************************************)
  724.  
  725. (*
  726.  * Enumerate all players in the current session
  727.  *)
  728.   DPENUMPLAYERS_ALL = $00000000;
  729.   DPENUMGROUPS_ALL = DPENUMPLAYERS_ALL;
  730.  
  731. (*
  732.  * Enumerate only local (created by this application) players
  733.  * or groups
  734.  *)
  735.   DPENUMPLAYERS_LOCAL = $00000008;
  736.   DPENUMGROUPS_LOCAL = DPENUMPLAYERS_LOCAL;
  737.  
  738. (*
  739.  * Enumerate only remote (non-local) players
  740.  * or groups
  741.  *)
  742.   DPENUMPLAYERS_REMOTE = $00000010;
  743.   DPENUMGROUPS_REMOTE = DPENUMPLAYERS_REMOTE;
  744.  
  745. (*
  746.  * Enumerate groups along with the players
  747.  *)
  748.   DPENUMPLAYERS_GROUP = $00000020;
  749.  
  750. (*
  751.  * Enumerate players or groups in another session
  752.  * (must supply lpguidInstance)
  753.  *)
  754.   DPENUMPLAYERS_SESSION = $00000080;
  755.   DPENUMGROUPS_SESSION = DPENUMPLAYERS_SESSION;
  756.  
  757. (*
  758.  * Enumerate server players
  759.  *)
  760.   DPENUMPLAYERS_SERVERPLAYER = $00000100;
  761.  
  762. (*
  763.  * Enumerate spectator players
  764.  *)
  765.   DPENUMPLAYERS_SPECTATOR = $00000200;
  766.  
  767. (*
  768.  * Enumerate shortcut groups
  769.  *)
  770.   DPENUMGROUPS_SHORTCUT = $00000400;
  771.  
  772. (*
  773.  * Enumerate staging area groups
  774.  *)
  775.   DPENUMGROUPS_STAGINGAREA = $00000800;
  776.  
  777. (*
  778.  * Enumerate hidden groups
  779.  *)
  780.   DPENUMGROUPS_HIDDEN = $00001000;
  781.  
  782. (*
  783.  * Enumerate the group's owner
  784.  *)
  785.   DPENUMPLAYERS_OWNER = $00002000;
  786.  
  787. (****************************************************************************
  788.  *
  789.  * CreatePlayer API flags
  790.  *
  791.  ****************************************************************************)
  792.  
  793. (*
  794.  * This flag indicates that this player should be designated
  795.  * the server player. The app should specify this at CreatePlayer.
  796.  *)
  797.   DPPLAYER_SERVERPLAYER = DPENUMPLAYERS_SERVERPLAYER;
  798.  
  799. (*
  800.  * This flag indicates that this player should be designated
  801.  * a spectator. The app should specify this at CreatePlayer.
  802.  *)
  803.   DPPLAYER_SPECTATOR = DPENUMPLAYERS_SPECTATOR;
  804.  
  805. (*
  806.  * This flag indicates that this player was created locally.
  807.  * (returned from GetPlayerFlags)
  808.  *)
  809.   DPPLAYER_LOCAL = DPENUMPLAYERS_LOCAL;
  810.  
  811. (*
  812.  * This flag indicates that this player is the group's owner
  813.  * (Only returned in EnumGroupPlayers)
  814.  *)
  815.   DPPLAYER_OWNER = DPENUMPLAYERS_OWNER;
  816.  
  817. (****************************************************************************
  818.  *
  819.  * CreateGroup API flags
  820.  *
  821.  ****************************************************************************)
  822.  
  823. (*
  824.  * This flag indicates that the StartSession can be called on the group.
  825.  * The app should specify this at CreateGroup, or CreateGroupInGroup.
  826.  *)
  827.   DPGROUP_STAGINGAREA = DPENUMGROUPS_STAGINGAREA;
  828.  
  829. (*
  830.  * This flag indicates that this group was created locally.
  831.  * (returned from GetGroupFlags)
  832.  *)
  833.   DPGROUP_LOCAL = DPENUMGROUPS_LOCAL;
  834.  
  835. (*
  836.  * This flag indicates that this group was created hidden.
  837.  *)
  838.   DPGROUP_HIDDEN = DPENUMGROUPS_HIDDEN;
  839.  
  840. (****************************************************************************
  841.  *
  842.  * EnumSessions API flags
  843.  *
  844.  ****************************************************************************)
  845.  
  846. (*
  847.  * Enumerate sessions which can be joined
  848.  *)
  849.   DPENUMSESSIONS_AVAILABLE = $00000001;
  850.  
  851. (*
  852.  * Enumerate all sessions even if they can't be joined.
  853.  *)
  854.   DPENUMSESSIONS_ALL = $00000002;
  855.  
  856. (*
  857.  * Start an asynchronous enum sessions
  858.  *)
  859.   DPENUMSESSIONS_ASYNC = $00000010;
  860.  
  861. (*
  862.  * Stop an asynchronous enum sessions
  863.  *)
  864.   DPENUMSESSIONS_STOPASYNC = $00000020;
  865.  
  866. (*
  867.  * Enumerate sessions even if they require a password
  868.  *)
  869.   DPENUMSESSIONS_PASSWORDREQUIRED = $00000040;
  870.  
  871. (*
  872.  * Return status about progress of enumeration instead of
  873.  * showing any status dialogs.
  874.  *)
  875.   DPENUMSESSIONS_RETURNSTATUS = $00000080;
  876.  
  877. (****************************************************************************
  878.  *
  879.  * GetCaps and GetPlayerCaps API flags
  880.  *
  881.  ****************************************************************************)
  882.  
  883. (*
  884.  * The latency returned should be for guaranteed message sending.
  885.  * Default is non-guaranteed messaging.
  886.  *)
  887.   DPGETCAPS_GUARANTEED = $00000001;
  888.  
  889. (****************************************************************************
  890.  *
  891.  * GetGroupData, GetPlayerData API flags
  892.  * Remote and local Group/Player data is maintained separately.
  893.  * Default is DPGET_REMOTE.
  894.  *
  895.  ****************************************************************************)
  896.  
  897. (*
  898.  * Get the remote data (set by any DirectPlay object in
  899.  * the session using DPSET_REMOTE)
  900.  *)
  901.   DPGET_REMOTE = $00000000;
  902.  
  903. (*
  904.  * Get the local data (set by this DirectPlay object
  905.  * using DPSET_LOCAL)
  906.  *)
  907.   DPGET_LOCAL = $00000001;
  908.  
  909. (****************************************************************************
  910.  *
  911.  * Open API flags
  912.  *
  913.  ****************************************************************************)
  914.  
  915. (*
  916.  * Join the session that is described by the DPSESSIONDESC2 structure
  917.  *)
  918.   DPOPEN_JOIN = $00000001;
  919.  
  920. (*
  921.  * Create a new session as described by the DPSESSIONDESC2 structure
  922.  *)
  923.   DPOPEN_CREATE = $00000002;
  924.  
  925. (*
  926.  * Return status about progress of open instead of showing
  927.  * any status dialogs.
  928.  *)
  929.   DPOPEN_RETURNSTATUS = DPENUMSESSIONS_RETURNSTATUS;
  930.  
  931. (****************************************************************************
  932.  *
  933.  * DPLCONNECTION flags
  934.  *
  935.  ****************************************************************************)
  936.  
  937. (*
  938.  * This application should create a new session as
  939.  * described by the DPSESIONDESC structure
  940.  *)
  941.   DPLCONNECTION_CREATESESSION = DPOPEN_CREATE;
  942.  
  943. (*
  944.  * This application should join the session described by
  945.  * the DPSESIONDESC structure with the lpAddress data
  946.  *)
  947.   DPLCONNECTION_JOINSESSION = DPOPEN_JOIN;
  948.  
  949. (****************************************************************************
  950.  *
  951.  * Receive API flags
  952.  * Default is DPRECEIVE_ALL
  953.  *
  954.  ****************************************************************************)
  955.  
  956. (*
  957.  * Get the first message in the queue
  958.  *)
  959.   DPRECEIVE_ALL = $00000001;
  960.  
  961. (*
  962.  * Get the first message in the queue directed to a specific player
  963.  *)
  964.   DPRECEIVE_TOPLAYER = $00000002;
  965.  
  966. (*
  967.  * Get the first message in the queue from a specific player
  968.  *)
  969.   DPRECEIVE_FROMPLAYER = $00000004;
  970.  
  971. (*
  972.  * Get the message but don't remove it from the queue
  973.  *)
  974.   DPRECEIVE_PEEK = $00000008;
  975.  
  976. (****************************************************************************
  977.  *
  978.  * Send API flags
  979.  *
  980.  ****************************************************************************)
  981.  
  982. (*
  983.  * Send the message using a guaranteed send method.
  984.  * Default is non-guaranteed.
  985.  *)
  986.   DPSEND_GUARANTEED = $00000001;
  987.  
  988. (*
  989.  * This flag is obsolete. It is ignored by DirectPlay
  990.  *)
  991.   DPSEND_HIGHPRIORITY = $00000002;
  992.  
  993. (*
  994.  * This flag is obsolete. It is ignored by DirectPlay
  995.  *)
  996.   DPSEND_OPENSTREAM = $00000008;
  997.  
  998. (*
  999.  * This flag is obsolete. It is ignored by DirectPlay
  1000.  *)
  1001.   DPSEND_CLOSESTREAM = $00000010;
  1002.  
  1003. (*
  1004.  * Send the message digitally signed to ensure authenticity.
  1005.  *)
  1006.   DPSEND_SIGNED = $00000020;
  1007.  
  1008. (*
  1009.  * Send the message with encryption to ensure privacy.
  1010.  *)
  1011.   DPSEND_ENCRYPTED = $00000040;
  1012.  
  1013. (*
  1014.  * The message is a lobby system message
  1015.  *)
  1016.   DPSEND_LOBBYSYSTEMMESSAGE = $00000080;
  1017.  
  1018. (*
  1019.  * andyco - added this so we can make addforward async.
  1020.  * needs to be sanitized when we add / expose full async
  1021.  * support.  8/3/97.
  1022.  *)
  1023.   DPSEND_ASYNC = $00000200;
  1024.  
  1025. (*
  1026.  * When a message is completed, don't tell me.
  1027.  * by default the application is notified with a system message.
  1028.  *)
  1029.   DPSEND_NOSENDCOMPLETEMSG = $00000400;
  1030.  
  1031. (*
  1032.  * Maximum priority for sends available to applications
  1033.  *)
  1034.   DPSEND_MAX_PRI = $0000FFFF;
  1035.   DPSEND_MAX_PRIORITY = DPSEND_MAX_PRI;
  1036.  
  1037. (****************************************************************************
  1038.  *
  1039.  * SetGroupData, SetGroupName, SetPlayerData, SetPlayerName,
  1040.  * SetSessionDesc API flags.
  1041.  * Default is DPSET_REMOTE.
  1042.  *
  1043.  ****************************************************************************)
  1044.  
  1045. (*
  1046.  * Propagate the data to all players in the session
  1047.  *)
  1048.   DPSET_REMOTE = $00000000;
  1049.  
  1050. (*
  1051.  * Do not propagate the data to other players
  1052.  *)
  1053.   DPSET_LOCAL = $00000001;
  1054.  
  1055. (*
  1056.  * Used with DPSET_REMOTE, use guaranteed message send to
  1057.  * propagate the data
  1058.  *)
  1059.   DPSET_GUARANTEED = $00000002;
  1060.  
  1061. (****************************************************************************
  1062.  *
  1063.  * GetMessageQueue API flags.
  1064.  * Default is DPMESSAGEQUEUE_SEND
  1065.  *
  1066.  ****************************************************************************)
  1067.  
  1068. (*
  1069.  * Get Send Queue - requires Service Provider Support
  1070.  *)
  1071.   DPMESSAGEQUEUE_SEND = $00000001;
  1072.  
  1073. (*
  1074.  * Get Receive Queue
  1075.  *)
  1076.   DPMESSAGEQUEUE_RECEIVE = $00000002;
  1077.  
  1078. (****************************************************************************
  1079.  *
  1080.  * Connect API flags
  1081.  *
  1082.  ****************************************************************************)
  1083.  
  1084. (*
  1085.  * Start an asynchronous connect which returns status codes
  1086.  *)
  1087.   DPCONNECT_RETURNSTATUS = DPENUMSESSIONS_RETURNSTATUS;
  1088.  
  1089. (****************************************************************************
  1090.  *
  1091.  * DirectPlay system messages and message data structures
  1092.  *
  1093.  * All system message come 'From' player DPID_SYSMSG.  To determine what type
  1094.  * of message it is, cast the lpData from Receive to TDPMsg_Generic and check
  1095.  * the dwType member against one of the following DPSYS_xxx constants. Once
  1096.  * a match is found, cast the lpData to the corresponding of the DPMSG_xxx
  1097.  * structures to access the data of the message.
  1098.  *
  1099.  ****************************************************************************)
  1100.  
  1101. (*
  1102.  * A new player or group has been created in the session
  1103.  * Use TDPMsg_CreatePlayerOrGroup.  Check dwPlayerType to see if it
  1104.  * is a player or a group.
  1105.  *)
  1106.   DPSYS_CREATEPLAYERORGROUP = $0003;
  1107.  
  1108. (*
  1109.  * A player has been deleted from the session
  1110.  * Use TDPMsg_DestroyPlayerOrGroup
  1111.  *)
  1112.   DPSYS_DESTROYPLAYERORGROUP = $0005;
  1113.  
  1114. (*
  1115.  * A player has been added to a group
  1116.  * Use DPMSG_ADDPLAYERTOGROUP
  1117.  *)
  1118.   DPSYS_ADDPLAYERTOGROUP = $0007;
  1119.  
  1120. (*
  1121.  * A player has been removed from a group
  1122.  * Use DPMSG_DELETEPLAYERFROMGROUP
  1123.  *)
  1124.   DPSYS_DELETEPLAYERFROMGROUP = $0021;
  1125.  
  1126. (*
  1127.  * This DirectPlay object lost its connection with all the
  1128.  * other players in the session.
  1129.  * Use DPMSG_SESSIONLOST.
  1130.  *)
  1131.   DPSYS_SESSIONLOST = $0031;
  1132.  
  1133. (*
  1134.  * The current host has left the session.
  1135.  * This DirectPlay object is now the host.
  1136.  * Use DPMSG_HOST.
  1137.  *)
  1138.   DPSYS_HOST = $0101;
  1139.  
  1140. (*
  1141.  * The remote data associated with a player or
  1142.  * group has changed. Check dwPlayerType to see
  1143.  * if it is a player or a group
  1144.  * Use DPMSG_SETPLAYERORGROUPDATA
  1145.  *)
  1146.   DPSYS_SETPLAYERORGROUPDATA = $0102;
  1147.  
  1148. (*
  1149.  * The name of a player or group has changed.
  1150.  * Check dwPlayerType to see if it is a player
  1151.  * or a group.
  1152.  * Use TDPMsg_SetPlayerOrGroupName
  1153.  *)
  1154.   DPSYS_SETPLAYERORGROUPNAME = $0103;
  1155.  
  1156. (*
  1157.  * The session description has changed.
  1158.  * Use DPMSG_SETSESSIONDESC
  1159.  *)
  1160.   DPSYS_SETSESSIONDESC = $0104;
  1161.  
  1162. (*
  1163.  * A group has been added to a group
  1164.  * Use TDPMsg_AddGroupToGroup
  1165.  *)
  1166.   DPSYS_ADDGROUPTOGROUP = $0105;
  1167.  
  1168. (*
  1169.  * A group has been removed from a group
  1170.  * Use DPMsg_DeleteGroupFromGroup
  1171.  *)
  1172.   DPSYS_DELETEGROUPFROMGROUP = $0106;
  1173.  
  1174. (*
  1175.  * A secure player-player message has arrived.
  1176.  * Use DPMSG_SECUREMESSAGE
  1177.  *)
  1178.   DPSYS_SECUREMESSAGE = $0107;
  1179.  
  1180. (*
  1181.  * Start a new session.
  1182.  * Use DPMSG_STARTSESSION
  1183.  *)
  1184.   DPSYS_STARTSESSION = $0108;
  1185.  
  1186. (*
  1187.  * A chat message has arrived
  1188.  * Use DPMSG_CHAT
  1189.  *)
  1190.   DPSYS_CHAT = $0109;
  1191.  
  1192. (*
  1193.  * The owner of a group has changed
  1194.  * Use DPMSG_SETGROUPOWNER
  1195.  *)
  1196.   DPSYS_SETGROUPOWNER = $010A;
  1197.  
  1198. (*
  1199.  * An async send has finished, failed or been cancelled
  1200.  * Use DPMSG_SENDCOMPLETE
  1201.  *)
  1202.   DPSYS_SENDCOMPLETE = $010D;
  1203.  
  1204. (*
  1205.  * Used in the dwPlayerType field to indicate if it applies to a group
  1206.  * or a player
  1207.  *)
  1208.   DPPLAYERTYPE_GROUP = $00000000;
  1209.   DPPLAYERTYPE_PLAYER = $00000001;
  1210.  
  1211. type
  1212. (*
  1213.  * TDPMsg_Generic
  1214.  * Generic message structure used to identify the message type.
  1215.  *)
  1216.   PDPMsg_Generic = ^TDPMsg_Generic;
  1217.   TDPMsg_Generic = packed record
  1218.     dwType: DWORD; // Message type
  1219.   end;
  1220.  
  1221. (*
  1222.  * TDPMsg_CreatePlayerOrGroup
  1223.  * System message generated when a new player or group
  1224.  * created in the session with information about it.
  1225.  *)
  1226.   PDPMsg_CreatePlayerOrGroup = ^TDPMsg_CreatePlayerOrGroup;
  1227.   TDPMsg_CreatePlayerOrGroup = packed record
  1228.     dwType: DWORD; // Message type
  1229.     dwPlayerType: DWORD; // Is it a player or group
  1230.     DPID: TDPID; // ID of the player or group
  1231.     dwCurrentPlayers: DWORD; // current # players & groups in session
  1232.     lpData: Pointer; // pointer to remote data
  1233.     dwDataSize: DWORD; // size of remote data
  1234.     dpnName: TDPName; // structure with name info
  1235.                                // the following fields are only available when using
  1236.                                // the IDirectPlay3 interface or greater
  1237.     dpIdParent: TDPID; // id of parent group
  1238.     dwFlags: DWORD; // player or group flags
  1239.   end;
  1240.  
  1241. (*
  1242.  * TDPMsg_DestroyPlayerOrGroup
  1243.  * System message generated when a player or group is being
  1244.  * destroyed in the session with information about it.
  1245.  *)
  1246.   PDPMsg_DestroyPlayerOrGroup = ^TDPMsg_DestroyPlayerOrGroup;
  1247.   TDPMsg_DestroyPlayerOrGroup = packed record
  1248.     dwType: DWORD; // Message type
  1249.     dwPlayerType: DWORD; // Is it a player or group
  1250.     DPID: TDPID; // player ID being deleted
  1251.     lpLocalData: Pointer; // copy of players local data
  1252.     dwLocalDataSize: DWORD; // sizeof local data
  1253.     lpRemoteData: Pointer; // copy of players remote data
  1254.     dwRemoteDataSize: DWORD; // sizeof remote data
  1255.                                // the following fields are only available when using
  1256.                                // the IDirectPlay3 interface or greater
  1257.     dpnName: TDPName; // structure with name info
  1258.     dpIdParent: TDPID; // id of parent group
  1259.     dwFlags: DWORD; // player or group flags
  1260.   end;
  1261.  
  1262. (*
  1263.  * DPMSG_ADDPLAYERTOGROUP
  1264.  * System message generated when a player is being added
  1265.  * to a group.
  1266.  *)
  1267.   PDPMsg_AddPlayerToGroup = ^TDPMsg_AddPlayerToGroup;
  1268.   TDPMsg_AddPlayerToGroup = packed record
  1269.     dwType: DWORD; // Message type
  1270.     dpIdGroup: TDPID; // group ID being added to
  1271.     dpIdPlayer: TDPID; // player ID being added
  1272.   end;
  1273.  
  1274. (*
  1275.  * DPMSG_DELETEPLAYERFROMGROUP
  1276.  * System message generated when a player is being
  1277.  * removed from a group
  1278.  *)
  1279.   PDPMsg_DeletePlayerFromGroup = ^TDPMsg_DeletePlayerFromGroup;
  1280.   TDPMsg_DeletePlayerFromGroup = TDPMsg_AddPlayerToGroup;
  1281.  
  1282. (*
  1283.  * TDPMsg_AddGroupToGroup
  1284.  * System message generated when a group is being added
  1285.  * to a group.
  1286.  *)
  1287.   PDPMsg_AddGroupToGroup = ^TDPMsg_AddGroupToGroup;
  1288.   TDPMsg_AddGroupToGroup = packed record
  1289.     dwType: DWORD; // Message type
  1290.     dpIdParentGroup: TDPID; // group ID being added to
  1291.     dpIdGroup: TDPID; // group ID being added
  1292.   end;
  1293.  
  1294. (*
  1295.  * DPMsg_DeleteGroupFromGroup
  1296.  * System message generated when a GROUP is being
  1297.  * removed from a group
  1298.  *)
  1299.   PDPMsg_DeleteGroupFromGroup = ^TDPMsg_DeleteGroupFromGroup;
  1300.   TDPMsg_DeleteGroupFromGroup = TDPMsg_AddGroupToGroup;
  1301.  
  1302. (*
  1303.  * DPMSG_SETPLAYERORGROUPDATA
  1304.  * System message generated when remote data for a player or
  1305.  * group has changed.
  1306.  *)
  1307.   PDPMsg_SetPlayerOrGroupData = ^TDPMsg_SetPlayerOrGroupData;
  1308.   TDPMsg_SetPlayerOrGroupData = packed record
  1309.     dwType: DWORD; // Message type
  1310.     dwPlayerType: DWORD; // Is it a player or group
  1311.     DPID: TDPID; // ID of player or group
  1312.     lpData: Pointer; // pointer to remote data
  1313.     dwDataSize: DWORD; // size of remote data
  1314.   end;
  1315.  
  1316. (*
  1317.  * DPMSG_SETPLAYERORGROUPNAME
  1318.  * System message generated when the name of a player or
  1319.  * group has changed.
  1320.  *)
  1321.   PDPMsg_SetPlayerOrGroupName = ^TDPMsg_SetPlayerOrGroupName;
  1322.   TDPMsg_SetPlayerOrGroupName = packed record
  1323.     dwType: DWORD; // Message type
  1324.     dwPlayerType: DWORD; // Is it a player or group
  1325.     DPID: TDPID; // ID of player or group
  1326.     dpnName: TDPName; // structure with new name info
  1327.   end;
  1328.  
  1329. (*
  1330.  * DPMSG_SETSESSIONDESC
  1331.  * System message generated when session desc has changed
  1332.  *)
  1333.   PDPMsg_SetSessionDesc = ^TDPMsg_SetSessionDesc;
  1334.   TDPMsg_SetSessionDesc = packed record
  1335.     dwType: DWORD; // Message type
  1336.     dpDesc: TDPSessionDesc2; // Session desc
  1337.   end;
  1338.  
  1339. (*
  1340.  * DPMSG_HOST
  1341.  * System message generated when the host has migrated to this
  1342.  * DirectPlay object.
  1343.  *
  1344.  *)
  1345.   PDPMsg_Host = ^TDPMsg_Host;
  1346.   TDPMsg_Host = TDPMsg_Generic;
  1347.  
  1348. (*
  1349.  * DPMSG_SESSIONLOST
  1350.  * System message generated when the connection to the session is lost.
  1351.  *
  1352.  *)
  1353.   PDPMsg_SessionLost = ^TDPMsg_SessionLost;
  1354.   TDPMsg_SessionLost = TDPMsg_Generic;
  1355.  
  1356. (*
  1357.  * DPMSG_SECUREMESSAGE
  1358.  * System message generated when a player requests a secure send
  1359.  *)
  1360.   PDPMsg_SecureMessage = ^TDPMsg_SecureMessage;
  1361.   TDPMsg_SecureMessage = packed record
  1362.     dwType: DWORD; // Message Type
  1363.     dwFlags: DWORD; // Signed/Encrypted
  1364.     dpIdFrom: TDPID; // ID of Sending Player
  1365.     lpData: Pointer; // Player message
  1366.     dwDataSize: DWORD; // Size of player message
  1367.   end;
  1368.  
  1369. (*
  1370.  * DPMSG_STARTSESSION
  1371.  * System message containing all information required to
  1372.  * start a new session
  1373.  *)
  1374.   PDPMsg_StartSession = ^TDPMsg_StartSession;
  1375.   TDPMsg_StartSession = packed record
  1376.     dwType: DWORD; // Message type
  1377.     lpConn: PDPLConnection; // TDPLConnection structure
  1378.   end;
  1379.  
  1380. (*
  1381.  * DPMSG_CHAT
  1382.  * System message containing a chat message
  1383.  *)
  1384.   PDPMsg_Chat = ^TDPMsg_Chat;
  1385.   TDPMsg_Chat = packed record
  1386.     dwType: DWORD; // Message type
  1387.     dwFlags: DWORD; // Message flags
  1388.     idFromPlayer: TDPID; // ID of the Sending Player
  1389.     idToPlayer: TDPID; // ID of the To Player
  1390.     idToGroup: TDPID; // ID of the To Group
  1391.     lpChat: PDPChat; // Pointer to a structure containing the chat message
  1392.   end;
  1393.  
  1394. (*
  1395.  * DPMSG_SETGROUPOWNER
  1396.  * System message generated when the owner of a group has changed
  1397.  *)
  1398.   PDPMsg_SetGroupOwner = ^TDPMsg_SetGroupOwner;
  1399.   TDPMsg_SetGroupOwner = packed record
  1400.     dwType: DWORD; // Message type
  1401.     idGroup: TDPID; // ID of the group
  1402.     idNewOwner: TDPID; // ID of the player that is the new owner
  1403.     idOldOwner: TDPID; // ID of the player that used to be the owner
  1404.   end;
  1405.  
  1406. (*
  1407.  * DPMSG_SENDCOMPLETE
  1408.  * System message generated when finished with an Async Send message
  1409.  *
  1410.  * NOTE SENDPARMS has an overlay for DPMSG_SENDCOMPLETE, don't
  1411.  *                change this message w/o changing SENDPARMS.
  1412.  *)
  1413.   PDPMsg_SendComplete = ^TDPMsg_SendComplete;
  1414.   TDPMsg_SendComplete = packed record
  1415.     dwType: DWORD; // Message type
  1416.     idFrom: TDPID;
  1417.     idTo: TDPID;
  1418.     dwFlags: DWORD;
  1419.     dwPriority: DWORD;
  1420.     dwTimeout: DWORD;
  1421.     lpvContext: Pointer;
  1422.     dwMsgID: DWORD;
  1423.     hr: HRESULT;
  1424.     dwSendTime: DWORD;
  1425.   end;
  1426.  
  1427. (****************************************************************************
  1428.  *
  1429.  * DIRECTPLAY ERRORS
  1430.  *
  1431.  * Errors are represented by negative values and cannot be combined.
  1432.  *
  1433.  ****************************************************************************)
  1434. const
  1435.   MAKE_DPHRESULT = HResult($88770000);
  1436.  
  1437.   DP_OK = S_OK;
  1438.   DPERR_ALREADYINITIALIZED = MAKE_DPHRESULT + 5;
  1439.   DPERR_ACCESSDENIED = MAKE_DPHRESULT + 10;
  1440.   DPERR_ACTIVEPLAYERS = MAKE_DPHRESULT + 20;
  1441.   DPERR_BUFFERTOOSMALL = MAKE_DPHRESULT + 30;
  1442.   DPERR_CANTADDPLAYER = MAKE_DPHRESULT + 40;
  1443.   DPERR_CANTCREATEGROUP = MAKE_DPHRESULT + 50;
  1444.   DPERR_CANTCREATEPLAYER = MAKE_DPHRESULT + 60;
  1445.   DPERR_CANTCREATESESSION = MAKE_DPHRESULT + 70;
  1446.   DPERR_CAPSNOTAVAILABLEYET = MAKE_DPHRESULT + 80;
  1447.   DPERR_EXCEPTION = MAKE_DPHRESULT + 90;
  1448.   DPERR_GENERIC = E_FAIL;
  1449.   DPERR_INVALIDFLAGS = MAKE_DPHRESULT + 120;
  1450.   DPERR_INVALIDOBJECT = MAKE_DPHRESULT + 130;
  1451.   DPERR_INVALIDPARAM = E_INVALIDARG;
  1452.   DPERR_INVALIDPARAMS = DPERR_INVALIDPARAM;
  1453.   DPERR_INVALIDPLAYER = MAKE_DPHRESULT + 150;
  1454.   DPERR_INVALIDGROUP = MAKE_DPHRESULT + 155;
  1455.   DPERR_NOCAPS = MAKE_DPHRESULT + 160;
  1456.   DPERR_NOCONNECTION = MAKE_DPHRESULT + 170;
  1457.   DPERR_NOMEMORY = E_OUTOFMEMORY;
  1458.   DPERR_OUTOFMEMORY = DPERR_NOMEMORY;
  1459.   DPERR_NOMESSAGES = MAKE_DPHRESULT + 190;
  1460.   DPERR_NONAMESERVERFOUND = MAKE_DPHRESULT + 200;
  1461.   DPERR_NOPLAYERS = MAKE_DPHRESULT + 210;
  1462.   DPERR_NOSESSIONS = MAKE_DPHRESULT + 220;
  1463.   DPERR_PENDING = E_PENDING;
  1464.   DPERR_SENDTOOBIG = MAKE_DPHRESULT + 230;
  1465.   DPERR_TIMEOUT = MAKE_DPHRESULT + 240;
  1466.   DPERR_UNAVAILABLE = MAKE_DPHRESULT + 250;
  1467.   DPERR_UNSUPPORTED = E_NOTIMPL;
  1468.   DPERR_BUSY = MAKE_DPHRESULT + 270;
  1469.   DPERR_USERCANCEL = MAKE_DPHRESULT + 280;
  1470.   DPERR_NOINTERFACE = E_NOINTERFACE;
  1471.   DPERR_CANNOTCREATESERVER = MAKE_DPHRESULT + 290;
  1472.   DPERR_PLAYERLOST = MAKE_DPHRESULT + 300;
  1473.   DPERR_SESSIONLOST = MAKE_DPHRESULT + 310;
  1474.   DPERR_UNINITIALIZED = MAKE_DPHRESULT + 320;
  1475.   DPERR_NONEWPLAYERS = MAKE_DPHRESULT + 330;
  1476.   DPERR_INVALIDPASSWORD = MAKE_DPHRESULT + 340;
  1477.   DPERR_CONNECTING = MAKE_DPHRESULT + 350;
  1478.   DPERR_CONNECTIONLOST = MAKE_DPHRESULT + 360;
  1479.   DPERR_UNKNOWNMESSAGE = MAKE_DPHRESULT + 370;
  1480.   DPERR_CANCELFAILED = MAKE_DPHRESULT + 380;
  1481.   DPERR_INVALIDPRIORITY = MAKE_DPHRESULT + 390;
  1482.   DPERR_NOTHANDLED = MAKE_DPHRESULT + 400;
  1483.   DPERR_CANCELLED = MAKE_DPHRESULT + 410;
  1484.   DPERR_ABORTED = MAKE_DPHRESULT + 420;
  1485.  
  1486.   DPERR_BUFFERTOOLARGE = MAKE_DPHRESULT + 1000;
  1487.   DPERR_CANTCREATEPROCESS = MAKE_DPHRESULT + 1010;
  1488.   DPERR_APPNOTSTARTED = MAKE_DPHRESULT + 1020;
  1489.   DPERR_INVALIDINTERFACE = MAKE_DPHRESULT + 1030;
  1490.   DPERR_NOSERVICEPROVIDER = MAKE_DPHRESULT + 1040;
  1491.   DPERR_UNKNOWNAPPLICATION = MAKE_DPHRESULT + 1050;
  1492.   DPERR_NOTLOBBIED = MAKE_DPHRESULT + 1070;
  1493.   DPERR_SERVICEPROVIDERLOADED = MAKE_DPHRESULT + 1080;
  1494.   DPERR_ALREADYREGISTERED = MAKE_DPHRESULT + 1090;
  1495.   DPERR_NOTREGISTERED = MAKE_DPHRESULT + 1100;
  1496.  
  1497. //
  1498. // Security related errors
  1499. //
  1500.   DPERR_AUTHENTICATIONFAILED = MAKE_DPHRESULT + 2000;
  1501.   DPERR_CANTLOADSSPI = MAKE_DPHRESULT + 2010;
  1502.   DPERR_ENCRYPTIONFAILED = MAKE_DPHRESULT + 2020;
  1503.   DPERR_SIGNFAILED = MAKE_DPHRESULT + 2030;
  1504.   DPERR_CANTLOADSECURITYPACKAGE = MAKE_DPHRESULT + 2040;
  1505.   DPERR_ENCRYPTIONNOTSUPPORTED = MAKE_DPHRESULT + 2050;
  1506.   DPERR_CANTLOADCAPI = MAKE_DPHRESULT + 2060;
  1507.   DPERR_NOTLOGGEDIN = MAKE_DPHRESULT + 2070;
  1508.   DPERR_LOGONDENIED = MAKE_DPHRESULT + 2080;
  1509.  
  1510. (****************************************************************************
  1511.  *
  1512.  *      dplay 1.0 obsolete structures + interfaces
  1513.  *      Included for compatibility only. New apps should
  1514.  *      use IDirectPlay2
  1515.  *
  1516.  ****************************************************************************)
  1517.  
  1518.   DPOPEN_OPENSESSION = DPOPEN_JOIN;
  1519.   DPOPEN_CREATESESSION = DPOPEN_CREATE;
  1520.  
  1521.   DPENUMSESSIONS_PREVIOUS = $00000004;
  1522.  
  1523.   DPENUMPLAYERS_PREVIOUS = $00000004;
  1524.  
  1525.   DPSEND_GUARANTEE = DPSEND_GUARANTEED;
  1526.   DPSEND_TRYONCE = $00000004;
  1527.  
  1528.   DPCAPS_NAMESERVICE = $00000001;
  1529.   DPCAPS_NAMESERVER = DPCAPS_ISHOST;
  1530.   DPCAPS_GUARANTEED = $00000004;
  1531.  
  1532.   DPLONGNAMELEN = 52;
  1533.   DPSHORTNAMELEN = 20;
  1534.   DPSESSIONNAMELEN = 32;
  1535.   DPPASSWORDLEN = 16;
  1536.   DPUSERRESERVED = 16;
  1537.  
  1538.   DPSYS_ADDPLAYER = $0003;
  1539.   DPSYS_DELETEPLAYER = $0005;
  1540.  
  1541.   DPSYS_DELETEGROUP = $0020;
  1542.   DPSYS_DELETEPLAYERFROMGRP = $0021;
  1543.   DPSYS_CONNECT = $484B;
  1544.  
  1545. type
  1546.   PDPMsg_AddPlayer = ^TDPMsg_AddPlayer;
  1547.   TDPMsg_AddPlayer = packed record
  1548.     dwType: DWORD;
  1549.     dwPlayerType: DWORD;
  1550.     DPID: TDPID;
  1551.     szLongName: array[0..DPLONGNAMELEN - 1] of Char;
  1552.     szShortName: array[0..DPSHORTNAMELEN - 1] of Char;
  1553.     dwCurrentPlayers: DWORD;
  1554.   end;
  1555.  
  1556.   PDPMsg_AddGroup = ^TDPMsg_AddGroup;
  1557.   TDPMsg_AddGroup = TDPMsg_AddPlayer;
  1558.  
  1559.   PDPMsg_GroupAdd = ^TDPMsg_GroupAdd;
  1560.   TDPMsg_GroupAdd = packed record
  1561.     dwType: DWORD;
  1562.     dpIdGroup: TDPID;
  1563.     dpIdPlayer: TDPID;
  1564.   end;
  1565.  
  1566.   PDPMsg_GroupDelete = ^TDPMsg_GroupDelete;
  1567.   TDPMsg_GroupDelete = TDPMsg_GroupAdd;
  1568.  
  1569.   PDPMsg_DeletePlayer = ^TDPMsg_DeletePlayer;
  1570.   TDPMsg_DeletePlayer = packed record
  1571.     dwType: DWORD;
  1572.     DPID: TDPID;
  1573.   end;
  1574.  
  1575.   TDPEnumPlayersCallback = function(dpId: TDPID; lpFriendlyName: PChar;
  1576.     lpFormalName: PChar; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall;
  1577.  
  1578.   PDPSessionDesc = ^TDPSessionDesc;
  1579.   TDPSessionDesc = packed record
  1580.     dwSize: DWORD;
  1581.     guidSession: TGUID;
  1582.     dwSession: DWORD;
  1583.     dwMaxPlayers: DWORD;
  1584.     dwCurrentPlayers: DWORD;
  1585.     dwFlags: DWORD;
  1586.     szSessionName: array[0..DPSESSIONNAMELEN - 1] of Char;
  1587.     szUserField: array[0..DPUSERRESERVED - 1] of Char;
  1588.     dwReserved1: DWORD;
  1589.     szPassword: array[0..DPPASSWORDLEN - 1] of Char;
  1590.     dwReserved2: DWORD;
  1591.     dwUser1: DWORD;
  1592.     dwUser2: DWORD;
  1593.     dwUser3: DWORD;
  1594.     dwUser4: DWORD;
  1595.   end;
  1596.  
  1597.   TDPEnumSessionsCallback = function(const lpDPSessionDesc: TDPSessionDesc;
  1598.     lpContext: Pointer; var lpdwTimeOut: DWORD; dwFlags: DWORD): BOOL; stdcall;
  1599.  
  1600. type
  1601.   IDirectPlay = interface(IUnknown)
  1602.     ['{5454e9a0-db65-11ce-921c-00aa006c4972}']
  1603.     (*** IDirectPlay methods ***)
  1604.     function AddPlayerToGroup(pidGroup: TDPID; pidPlayer: TDPID): HResult; stdcall;
  1605.     function Close: HResult; stdcall;
  1606.     function CreatePlayer(out lppidID: TDPID; lpPlayerFriendlyName: PChar;
  1607.       lpPlayerFormalName: PChar; lpEvent: PHandle): HResult; stdcall;
  1608.     function CreateGroup(out lppidID: TDPID; lpGroupFriendlyName: PChar;
  1609.       lpGroupFormalName: PChar): HResult; stdcall;
  1610.     function DeletePlayerFromGroup(pidGroup: TDPID; pidPlayer: TDPID): HResult; stdcall;
  1611.     function DestroyPlayer(pidID: TDPID): HResult; stdcall;
  1612.     function DestroyGroup(pidID: TDPID): HResult; stdcall;
  1613.     function EnableNewPlayers(bEnable: BOOL): HResult; stdcall;
  1614.     function EnumGroupPlayers(pidGroupPID: TDPID; lpEnumPlayersCallback:
  1615.       TDPEnumPlayersCallback; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
  1616.     function EnumGroups(dwSessionID: DWORD; lpEnumPlayersCallback:
  1617.       TDPEnumPlayersCallback; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
  1618.     function EnumPlayers(dwSessionId: DWORD; lpEnumPlayersCallback:
  1619.       TDPEnumPlayersCallback; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
  1620.     function EnumSessions(var lpSDesc: TDPSessionDesc; dwTimeout: DWORD;
  1621.       lpEnumSessionsCallback: TDPEnumSessionsCallback; lpContext: Pointer;
  1622.       dwFlags: DWORD): HResult; stdcall;
  1623.     function GetCaps(var lpDPCaps: TDPCaps): HResult; stdcall;
  1624.     function GetMessageCount(pidID: TDPID; var lpdwCount: DWORD): HResult; stdcall;
  1625.     function GetPlayerCaps(pidID: TDPID; var lpDPPlayerCaps: TDPCaps): HResult; stdcall;
  1626.     function GetPlayerName(pidID: TDPID; lpPlayerFriendlyName: PChar;
  1627.       var lpdwFriendlyNameLength: DWORD; lpPlayerFormalName: PChar;
  1628.       var lpdwFormalNameLength: DWORD): HResult; stdcall;
  1629.     function Initialize(const lpGUID: TGUID): HResult; stdcall;
  1630.     function Open(var lpSDesc: TDPSessionDesc): HResult; stdcall;
  1631.     function Receive(var lppidFrom, lppidTo: TDPID; dwFlags: DWORD;
  1632.       var lpvBuffer; var lpdwSize: DWORD): HResult; stdcall;
  1633.     function SaveSession(lpSessionName: PChar): HResult; stdcall;
  1634.     function Send(pidFrom: TDPID; pidTo: TDPID; dwFlags: DWORD;
  1635.       var lpvBuffer; dwBuffSize: DWORD): HResult; stdcall;
  1636.     function SetPlayerName(pidID: TDPID; lpPlayerFriendlyName: PChar;
  1637.       lpPlayerFormalName: PChar): HResult; stdcall;
  1638.   end;
  1639.  
  1640. (*
  1641.  * GUIDS used by DirectPlay objects
  1642.  *)
  1643.   IID_IDirectPlay2W = IDirectPlay2W;
  1644.   IID_IDirectPlay2A = IDirectPlay2A;
  1645.   IID_IDirectPlay2 = IDirectPlay2;
  1646.  
  1647.   IID_IDirectPlay3W = IDirectPlay3W;
  1648.   IID_IDirectPlay3A = IDirectPlay3A;
  1649.   IID_IDirectPlay3 = IDirectPlay3;
  1650.  
  1651.   IID_IDirectPlay4W = IDirectPlay4W;
  1652.   IID_IDirectPlay4A = IDirectPlay4A;
  1653.   IID_IDirectPlay4 = IDirectPlay4;
  1654.  
  1655.   IID_IDirectPlay = IDirectPlay;
  1656.  
  1657. var
  1658.   DirectPlayCreate: function(lpGUID: PGUID; out lplpDP: IDirectPlay;
  1659.     pUnk: IUnknown): HResult; stdcall;
  1660.  
  1661. (*==========================================================================;
  1662.  *
  1663.  *  Copyright (C) 1996-1997 Microsoft Corporation.  All Rights Reserved.
  1664.  *
  1665.  *  File:       dplobby.h
  1666.  *  Content:    DirectPlayLobby include file
  1667.  ***************************************************************************)
  1668.  
  1669. (*
  1670.  * GUIDS used by DirectPlay objects
  1671.  *)
  1672.  
  1673. const
  1674. (* {2FE8F810-B2A5-11d0-A787-0000F803ABFC} *)
  1675.   CLSID_DirectPlayLobby: TGUID =
  1676.   (D1: $2FE8F810; D2: $B2A5; D3: $11D0; D4: ($A7, $87, $00, $00, $F8, $3, $AB, $FC));
  1677.  
  1678. (****************************************************************************
  1679.  *
  1680.  * IDirectPlayLobby Structures
  1681.  *
  1682.  * Various structures used to invoke DirectPlayLobby.
  1683.  *
  1684.  ****************************************************************************)
  1685.  
  1686. type
  1687. (*
  1688.  * TDPLAppInfo
  1689.  * Used to hold information about a registered DirectPlay
  1690.  * application
  1691.  *)
  1692.   PDPLAppInfo = ^TDPLAppInfo;
  1693.   TDPLAppInfo = packed record
  1694.     dwSize: DWORD; // Size of this structure
  1695.     guidApplication: TGUID; // GUID of the Application
  1696.     case Integer of // Pointer to the Application Name
  1697.       0: (lpszAppName: PChar);
  1698.       1: (lpszAppNameW: PWideChar);
  1699.       3: (lpszAppNameA: PChar);
  1700.   end;
  1701.  
  1702. (*
  1703.  * TDPCompoundAddressElement
  1704.  *
  1705.  * An array of these is passed to CreateCompoundAddresses()
  1706.  *)
  1707.   PDPCompoundAddressElement = ^TDPCompoundAddressElement;
  1708.   TDPCompoundAddressElement = packed record
  1709.     guidDataType: TGUID;
  1710.     dwDataSize: DWORD;
  1711.     lpData: Pointer;
  1712.   end;
  1713.  
  1714. (*
  1715.  * TDPApplicationDesc
  1716.  * Used to register a DirectPlay application
  1717.  *)
  1718.   PDPApplicationDesc = ^TDPApplicationDesc;
  1719.   TDPApplicationDesc = packed record
  1720.     dwSize: DWORD;
  1721.     dwFlags: DWORD;
  1722.     case Integer of
  1723.       0: (lpszApplicationName: PChar;
  1724.         guidApplication: TGUID;
  1725.         lpszFilename: PChar;
  1726.         lpszCommandLine: PChar;
  1727.         lpszPath: PChar;
  1728.         lpszCurrentDirectory: PChar;
  1729.         lpszDescriptionA: PAnsiChar;
  1730.         lpszDescriptionW: PWideChar);
  1731.       1: (lpszApplicationNameA: PAnsiChar;
  1732.         filler1: TGUID;
  1733.         lpszFilenameA: PAnsiChar;
  1734.         lpszCommandLineA: PAnsiChar;
  1735.         lpszPathA: PAnsiChar;
  1736.         lpszCurrentDirectoryA: PAnsiChar);
  1737.       2: (lpszApplicationNameW: PWideChar;
  1738.         filler2: TGUID;
  1739.         lpszFilenameW: PWideChar;
  1740.         lpszCommandLineW: PWideChar;
  1741.         lpszPathW: PWideChar;
  1742.         lpszCurrentDirectoryW: PWideChar);
  1743.   end;
  1744.  
  1745. (*
  1746.  * TDPApplicationDesc2
  1747.  * Used to register a DirectPlay application
  1748.  *)
  1749.   PDPApplicationDesc2 = ^TDPApplicationDesc2;
  1750.   TDPApplicationDesc2 = packed record
  1751.     dwSize: DWORD;
  1752.     dwFlags: DWORD;
  1753.     case Integer of
  1754.       0: (lpszApplicationName: PChar;
  1755.         guidApplication: TGUID;
  1756.         lpszFilename: PChar;
  1757.         lpszCommandLine: PChar;
  1758.         lpszPath: PChar;
  1759.         lpszCurrentDirectory: PChar;
  1760.         lpszDescriptionA: PAnsiChar;
  1761.         lpszDescriptionW: PWideChar;
  1762.         lpszAppLauncherName: PChar);
  1763.       1: (lpszApplicationNameA: PAnsiChar;
  1764.         filler1: TGUID;
  1765.         lpszFilenameA: PAnsiChar;
  1766.         lpszCommandLineA: PAnsiChar;
  1767.         lpszPathA: PAnsiChar;
  1768.         lpszCurrentDirectoryA: PAnsiChar;
  1769.         filler3: PChar;
  1770.         filler4: PChar;
  1771.         lpszAppLauncherNameA: PAnsiChar);
  1772.       2: (lpszApplicationNameW: PWideChar;
  1773.         filler2: TGUID;
  1774.         lpszFilenameW: PWideChar;
  1775.         lpszCommandLineW: PWideChar;
  1776.         lpszPathW: PWideChar;
  1777.         lpszCurrentDirectoryW: PWideChar;
  1778.         filler5: PChar;
  1779.         filler6: PChar;
  1780.         lpszAppLauncherNameW: PWideChar);
  1781.   end;
  1782.  
  1783. (****************************************************************************
  1784.  *
  1785.  * Enumeration Method Callback Prototypes
  1786.  *
  1787.  ****************************************************************************)
  1788.  
  1789. (*
  1790.  * Callback for EnumAddress()
  1791.  *)
  1792.   TDPEnumAdressCallback = function(const guidDataType: TGUID;
  1793.     dwDataSize: DWORD; lpData: Pointer; lpContext: Pointer): BOOL; stdcall;
  1794.  
  1795. (*
  1796.  * Callback for EnumAddressTypes()
  1797.  *)
  1798.   TDPLEnumAddressTypesCallback = function(const guidDataType: TGUID;
  1799.     lpContext: Pointer; dwFlags: DWORD): BOOL; stdcall;
  1800.  
  1801. (*
  1802.  * Callback for EnumLocalApplications()
  1803.  *)
  1804.   TDPLEnumLocalApplicationsCallback = function(const lpAppInfo: TDPLAppInfo;
  1805.     lpContext: Pointer; dwFlags: DWORD): BOOL; stdcall;
  1806.  
  1807. (****************************************************************************
  1808.  *
  1809.  * IDirectPlayLobby (and IDirectPlayLobbyA) Interface
  1810.  *
  1811.  ****************************************************************************)
  1812.  
  1813. type
  1814.   IDirectPlayLobbyAW = interface(IUnknown)
  1815.     (*** IDirectPlayLobby methods ***)
  1816.     function Connect(dwFlags: DWORD; out lplpDP: IDirectPlay2;
  1817.       pUnk: IUnknown): HResult; stdcall;
  1818.     function CreateAddress(const guidSP, guidDataType: TGUID; var lpData;
  1819.       dwDataSize: DWORD; var lpAddress; var lpdwAddressSize: DWORD): HResult; stdcall;
  1820.     function EnumAddress(lpEnumAddressCallback: TDPEnumAdressCallback;
  1821.       var lpAddress; dwAddressSize: DWORD; lpContext: Pointer): HResult; stdcall;
  1822.     function EnumAddressTypes(lpEnumAddressTypeCallback:
  1823.       TDPLEnumAddressTypesCallback; const guidSP: TGUID; lpContext: Pointer;
  1824.       dwFlags: DWORD): HResult; stdcall;
  1825.     function EnumLocalApplications(lpEnumLocalAppCallback: TDPLEnumLocalApplicationsCallback;
  1826.       lpContext: Pointer; dwFlags: DWORD): HResult; stdcall;
  1827.     function GetConnectionSettings(dwAppID: DWORD; lpData: PDPLConnection;
  1828.       var lpdwDataSize: DWORD): HResult; stdcall;
  1829.     function ReceiveLobbyMessage(dwFlags: DWORD; dwAppID: DWORD;
  1830.       var lpdwMessageFlags: DWORD; lpData: Pointer; var lpdwDataSize: DWORD): HResult; stdcall;
  1831.     function RunApplication(dwFlags: DWORD; var lpdwAppId: DWORD;
  1832.       const lpConn: TDPLConnection; hReceiveEvent: THandle): HResult; stdcall;
  1833.     function SendLobbyMessage(dwFlags: DWORD; dwAppID: DWORD; const lpData;
  1834.       dwDataSize: DWORD): HResult; stdcall;
  1835.     function SetConnectionSettings(dwFlags: DWORD; dwAppID: DWORD;
  1836.       var lpConn: TDPLConnection): HResult; stdcall;
  1837.     function SetLobbyMessageEvent(dwFlags: DWORD; dwAppID: DWORD;
  1838.       hReceiveEvent: THandle): HResult; stdcall;
  1839.   end;
  1840.  
  1841.   IDirectPlayLobbyW = interface(IDirectPlayLobbyAW)
  1842.     ['{AF465C71-9588-11CF-A020-00AA006157AC}']
  1843.   end;
  1844.   IDirectPlayLobbyA = interface(IDirectPlayLobbyAW)
  1845.     ['{26C66A70-B367-11cf-A024-00AA006157AC}']
  1846.   end;
  1847.  
  1848. {$IFDEF UNICODE}
  1849.   IDirectPlayLobby = IDirectPlayLobbyW;
  1850. {$ELSE}
  1851.   IDirectPlayLobby = IDirectPlayLobbyA;
  1852. {$ENDIF}
  1853.  
  1854. (****************************************************************************
  1855.  *
  1856.  * IDirectPlayLobby2 (and IDirectPlayLobby2A) Interface
  1857.  *
  1858.  ****************************************************************************)
  1859.  
  1860.   IDirectPlayLobby2AW = interface(IDirectPlayLobbyAW)
  1861.     (*** IDirectPlayLobby2 methods ***)
  1862.     function CreateCompoundAddress(const lpElements: TDPCompoundAddressElement;
  1863.       dwElementCount: DWORD; lpAddress: Pointer; var lpdwAddressSize: DWORD): HResult; stdcall;
  1864.   end;
  1865.  
  1866.   IDirectPlayLobby2W = interface(IDirectPlayLobby2AW)
  1867.     ['{0194C220-A303-11D0-9C4F-00A0C905425E}']
  1868.   end;
  1869.   IDirectPlayLobby2A = interface(IDirectPlayLobby2AW)
  1870.     ['{1BB4AF80-A303-11d0-9C4F-00A0C905425E}']
  1871.   end;
  1872.  
  1873. {$IFDEF UNICODE}
  1874.   IDirectPlayLobby2 = IDirectPlayLobby2W;
  1875. {$ELSE}
  1876.   IDirectPlayLobby2 = IDirectPlayLobby2A;
  1877. {$ENDIF}
  1878.  
  1879. (****************************************************************************
  1880.  *
  1881.  * IDirectPlayLobby3 (and IDirectPlayLobby3A) Interface
  1882.  *
  1883.  ****************************************************************************)
  1884.  
  1885.   IDirectPlayLobby3AW = interface(IDirectPlayLobby2AW)
  1886.     (*** IDirectPlayLobby3 methods ***)
  1887.     function ConnectEx(dwFlags: DWORD; const riid: TGUID;
  1888.       out lplpDP; pUnk: IUnknown): HResult; stdcall;
  1889.     function RegisterApplication(dwFlags: DWORD;
  1890.       var lpAppDesc: TDPApplicationDesc): HResult; stdcall;
  1891.     function UnregisterApplication(dwFlags: DWORD;
  1892.       const guidApplication: TGUID): HResult; stdcall;
  1893.     function WaitForConnectionSettings(dwFlags: DWORD): HResult; stdcall;
  1894.   end;
  1895.  
  1896.   IDirectPlayLobby3W = interface(IDirectPlayLobby3AW)
  1897.     ['{2DB72490-652C-11d1-A7A8-0000F803ABFC}']
  1898.   end;
  1899.   IDirectPlayLobby3A = interface(IDirectPlayLobby3AW)
  1900.     ['{2DB72491-652C-11d1-A7A8-0000F803ABFC}']
  1901.   end;
  1902.  
  1903. {$IFDEF UNICODE}
  1904.   IDirectPlayLobby3 = IDirectPlayLobby3W;
  1905. {$ELSE}
  1906.   IDirectPlayLobby3 = IDirectPlayLobby3A;
  1907. {$ENDIF}
  1908.  
  1909.   IID_IDirectPlayLobbyW = IDirectPlayLobbyW;
  1910.   IID_IDirectPlayLobbyA = IDirectPlayLobbyA;
  1911.   IID_IDirectPlayLobby = IDirectPlayLobby;
  1912.  
  1913.   IID_IDirectPlayLobby2W = IDirectPlayLobby2W;
  1914.   IID_IDirectPlayLobby2A = IDirectPlayLobby2A;
  1915.   IID_IDirectPlayLobby2 = IDirectPlayLobby2;
  1916.  
  1917.   IID_IDirectPlayLobby3W = IDirectPlayLobby3W;
  1918.   IID_IDirectPlayLobby3A = IDirectPlayLobby3A;
  1919.   IID_IDirectPlayLobby3 = IDirectPlayLobby3;
  1920.  
  1921. (****************************************************************************
  1922.  *
  1923.  * DirectPlayLobby API Prototypes
  1924.  *
  1925.  ****************************************************************************)
  1926.  
  1927. var
  1928.   DirectPlayLobbyCreateW: function(lpguidSP: PGUID; out lplpDPL:
  1929.     IDirectPlayLobbyW; lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HResult; stdcall;
  1930.   DirectPlayLobbyCreateA: function(lpguidSP: PGUID; out lplpDPL:
  1931.     IDirectPlayLobbyA; lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HResult; stdcall;
  1932.   DirectPlayLobbyCreate: function(lpguidSP: PGUID; out lplpDPL:
  1933.     IDirectPlayLobby; lpUnk: IUnknown; lpData: Pointer; dwDataSize: DWORD): HResult; stdcall;
  1934.  
  1935. const
  1936. (****************************************************************************
  1937.  *
  1938.  * DirectPlayLobby Flags
  1939.  *
  1940.  ****************************************************************************)
  1941.  
  1942. (*
  1943.  *  This flag is used by IDirectPlayLobby.WaitForConnectionSettings to
  1944.  *  cancel a current wait that is in progress.
  1945.  *)
  1946.   DPLWAIT_CANCEL = $00000001;
  1947.  
  1948. (*
  1949.  *      This is a message flag used by ReceiveLobbyMessage.  It can be
  1950.  *      returned in the dwMessageFlags parameter to indicate a message from
  1951.  *      the system.
  1952.  *)
  1953.   DPLMSG_SYSTEM = $00000001;
  1954.  
  1955. (*
  1956.  *      This is a message flag used by ReceiveLobbyMessage and SendLobbyMessage.
  1957.  *  It is used to indicate that the message is a standard lobby message.
  1958.  *  TDPLMsg_SetProperty, TDPLMsg_SetPropertyResponse, TDPLMsg_GetProperty,
  1959.  *      TDPLMsg_GetPropertyResponse
  1960.  *)
  1961.   DPLMSG_STANDARD = $00000002;
  1962.  
  1963. type
  1964. (****************************************************************************
  1965.  *
  1966.  * DirectPlayLobby messages and message data structures
  1967.  *
  1968.  * All system messages have a dwMessageFlags value of DPLMSG_SYSTEM returned
  1969.  * from a call to ReceiveLobbyMessage.
  1970.  *
  1971.  * All standard messages have a dwMessageFlags value of DPLMSG_STANDARD returned
  1972.  * from a call to ReceiveLobbyMessage.
  1973.  *
  1974.  ****************************************************************************)
  1975.  
  1976. (*
  1977.  * TDPLMsg_Generic
  1978.  * Generic message structure used to identify the message type.
  1979.  *)
  1980.   PDPLMsg_Generic = ^TDPLMsg_Generic;
  1981.   TDPLMsg_Generic = packed record
  1982.     dwType: DWORD; // Message type
  1983.   end;
  1984.  
  1985. (*
  1986.  * TDPLMsg_SystemMessage
  1987.  * Generic message format for all system messages --
  1988.  * DPLSYS_CONNECTIONSETTINGSREAD, DPLSYS_DPLYCONNECTSUCCEEDED,
  1989.  * DPLSYS_DPLAYCONNECTFAILED, DPLSYS_APPTERMINATED, DPLSYS_NEWCONNECTIONSETTINGS
  1990.  *)
  1991.   PDPLMsg_SystemMessage = ^TDPLMsg_SystemMessage;
  1992.   TDPLMsg_SystemMessage = packed record
  1993.     dwType: DWORD; // Message type
  1994.     guidInstance: TGUID; // Instance GUID of the dplay session the message corresponds to
  1995.   end;
  1996.  
  1997. (*
  1998.  *  TDPLMsg_SetProperty
  1999.  *  Standard message sent by an application to a lobby to set a
  2000.  *  property
  2001.  *)
  2002.   PDPLMsg_SetProperty = ^TDPLMsg_SetProperty;
  2003.   TDPLMsg_SetProperty = packed record
  2004.     dwType: DWORD; // Message type
  2005.     dwRequestID: DWORD; // Request ID (DPL_NOCONFIRMATION if no confirmation desired)
  2006.     guidPlayer: TGUID; // Player GUID
  2007.     guidPropertyTag: TGUID; // Property GUID
  2008.     dwDataSize: DWORD; // Size of data
  2009.     dwPropertyData: array[0..0] of DWORD; // Buffer containing data
  2010.   end;
  2011.  
  2012. const
  2013.   DPL_NOCONFIRMATION = 0;
  2014.  
  2015. type
  2016. (*
  2017.  *  TDPLMsg_SetPropertyResponse
  2018.  *  Standard message returned by a lobby to confirm a
  2019.  *  TDPLMsg_SetProperty message.
  2020.  *)
  2021.   PDPLMsg_SetPropertyResponse = ^TDPLMsg_SetPropertyResponse;
  2022.   TDPLMsg_SetPropertyResponse = packed record
  2023.     dwType: DWORD; // Message type
  2024.     dwRequestID: DWORD; // Request ID
  2025.     guidPlayer: TGUID; // Player GUID
  2026.     guidPropertyTag: TGUID; // Property GUID
  2027.     hr: HResult; // Return Code
  2028.   end;
  2029.  
  2030. (*
  2031.  *  TDPLMsg_GetProperty
  2032.  *  Standard message sent by an application to a lobby to request
  2033.  *      the current value of a property
  2034.  *)
  2035.   PDPLMsg_GetProperty = ^TDPLMsg_GetProperty;
  2036.   TDPLMsg_GetProperty = packed record
  2037.     dwType: DWORD; // Message type
  2038.     dwRequestID: DWORD; // Request ID
  2039.     guidPlayer: TGUID; // Player GUID
  2040.     guidPropertyTag: TGUID; // Property GUID
  2041.   end;
  2042.   LPDPLMSG_GETPROPERTY = ^TDPLMsg_GetProperty;
  2043.  
  2044. (*
  2045.  *  TDPLMsg_GetPropertyResponse
  2046.  *  Standard message returned by a lobby in response to a
  2047.  *      TDPLMsg_GetProperty message.
  2048.  *)
  2049.   PDPLMsg_GetPropertyResponse = ^TDPLMsg_GetPropertyResponse;
  2050.   TDPLMsg_GetPropertyResponse = packed record
  2051.     dwType: DWORD; // Message type
  2052.     dwRequestID: DWORD; // Request ID
  2053.     guidPlayer: TGUID; // Player GUID
  2054.     guidPropertyTag: TGUID; // Property GUID
  2055.     hr: HResult; // Return Code
  2056.     dwDataSize: DWORD; // Size of data
  2057.     dwPropertyData: array[0..0] of DWORD; // Buffer containing data
  2058.   end;
  2059.  
  2060. (*
  2061.  *  TDPLMsg_NewSessionHost
  2062.  *  Standard message returned by a lobby in response to a
  2063.  *  the session host migrating to a new client
  2064.  *)
  2065.   PDPLMsg_NewSessionHost = ^TDPLMsg_NewSessionHost;
  2066.   TDPLMsg_NewSessionHost = packed record
  2067.     dwType: DWORD; // Message type
  2068.     guidInstance: TGUID; // Property GUID
  2069.   end;
  2070.  
  2071. const
  2072. (******************************************
  2073.  *
  2074.  *      DirectPlay Lobby message dwType values
  2075.  *
  2076.  *****************************************)
  2077.  
  2078. (*
  2079.  *  The application has read the connection settings.
  2080.  *  It is now O.K. for the lobby client to release
  2081.  *  its IDirectPlayLobby interface.
  2082.  *)
  2083.   DPLSYS_CONNECTIONSETTINGSREAD = $00000001;
  2084.  
  2085. (*
  2086.  *  The application's call to DirectPlayConnect failed
  2087.  *)
  2088.   DPLSYS_DPLAYCONNECTFAILED = $00000002;
  2089.  
  2090. (*
  2091.  *  The application has created a DirectPlay session.
  2092.  *)
  2093.   DPLSYS_DPLAYCONNECTSUCCEEDED = $00000003;
  2094.  
  2095. (*
  2096.  *  The application has terminated.
  2097.  *)
  2098.   DPLSYS_APPTERMINATED = $00000004;
  2099.  
  2100. (*
  2101.  *  The message is a TDPLMsg_SetProperty message.
  2102.  *)
  2103.   DPLSYS_SETPROPERTY = $00000005;
  2104.  
  2105. (*
  2106.  *  The message is a TDPLMsg_SetPropertyResponse message.
  2107.  *)
  2108.   DPLSYS_SETPROPERTYRESPONSE = $00000006;
  2109.  
  2110. (*
  2111.  *  The message is a TDPLMsg_GetProperty message.
  2112.  *)
  2113.   DPLSYS_GETPROPERTY = $00000007;
  2114.  
  2115. (*
  2116.  *  The message is a TDPLMsg_GetPropertyResponse message.
  2117.  *)
  2118.   DPLSYS_GETPROPERTYRESPONSE = $00000008;
  2119.  
  2120. (*
  2121.  *  The message is a TDPLMsg_NewSessionHost message.
  2122.  *)
  2123.   DPLSYS_NEWSESSIONHOST = $00000009;
  2124.  
  2125. (*
  2126.  *  New connection settings are available.
  2127.  *)
  2128.   DPLSYS_NEWCONNECTIONSETTINGS = $0000000A;
  2129.  
  2130. (****************************************************************************
  2131.  *
  2132.  * DirectPlay defined property GUIDs and associated data structures
  2133.  *
  2134.  ****************************************************************************)
  2135.  
  2136. (*
  2137.  * DPLPROPERTY_MessagesSupported
  2138.  *
  2139.  * Request whether the lobby supports standard.  Lobby with respond with either
  2140.  * TRUE or FALSE or may not respond at all.
  2141.  *
  2142.  * Property data is a single BOOL with TRUE or FALSE
  2143.  *)
  2144. // {762CCDA1-D916-11d0-BA39-00C04FD7ED67}
  2145.   DPLPROPERTY_MessagesSupported: TGUID =
  2146.   (D1: $762CCDA1; D2: $D916; D3: $11D0; D4: ($BA, $39, $00, $C0, $4F, $D7, $ED, $67));
  2147.  
  2148. (*
  2149.  * DPLPROPERTY_LobbyGuid
  2150.  *
  2151.  * Request the GUID that identifies the lobby software that the application
  2152.  * is communicating with.
  2153.  *
  2154.  * Property data is a single GUID.
  2155.  *)
  2156. // {F56920A0-D218-11d0-BA39-00C04FD7ED67}
  2157.   DPLPROPERTY_LobbyGuid: TGUID =
  2158.   (D1: $F56920A0; D2: $D218; D3: $11D0; D4: ($BA, $39, $00, $C0, $4F, $D7, $ED, $67));
  2159.  
  2160. (*
  2161.  * DPLPROPERTY_PlayerGuid
  2162.  *
  2163.  * Request the GUID that identifies the player on this machine for sending
  2164.  * property data back to the lobby.
  2165.  *
  2166.  * Property data is the DPLDATA_PLAYERDATA structure
  2167.  *)
  2168. // {B4319322-D20D-11d0-BA39-00C04FD7ED67}
  2169.   DPLPROPERTY_PlayerGuid: TGUID =
  2170.   (D1: $B4319322; D2: $D20D; D3: $11D0; D4: ($BA, $39, $00, $C0, $4F, $D7, $ED, $67));
  2171.  
  2172. type
  2173. (*
  2174.  * TDPLData_PlayerGUID
  2175.  *
  2176.  * Data structure to hold the GUID of the player and player creation flags
  2177.  * from the lobby.
  2178.  *)
  2179.   PDPLData_PlayerGUID = ^TDPLData_PlayerGUID;
  2180.   TDPLData_PlayerGUID = packed record
  2181.     guidPlayer: TGUID;
  2182.     dwPlayerFlags: DWORD;
  2183.   end;
  2184.  
  2185. const
  2186. (*
  2187.  * DPLPROPERTY_PlayerScore
  2188.  *
  2189.  * Used to send an array of long integers to the lobby indicating the
  2190.  * score of a player.
  2191.  *
  2192.  * Property data is the TDPLData_PlayerScore structure.
  2193.  *)
  2194. // {48784000-D219-11d0-BA39-00C04FD7ED67}
  2195.   DPLPROPERTY_PlayerScore: TGUID =
  2196.   (D1: $48784000; D2: $D219; D3: $11D0; D4: ($BA, $39, $00, $C0, $4F, $D7, $ED, $67));
  2197.  
  2198. type
  2199. (*
  2200.  * TDPLData_PlayerScore
  2201.  *
  2202.  * Data structure to hold an array of long integers representing a player score.
  2203.  * Application must allocate enough memory to hold all the scores.
  2204.  *)
  2205.   PDPLData_PlayerScore = ^TDPLData_PlayerScore;
  2206.   TDPLData_PlayerScore = packed record
  2207.     dwScoreCount: DWORD;
  2208.     Score: array[0..0] of Longint;
  2209.   end;
  2210.  
  2211. (****************************************************************************
  2212.  *
  2213.  * DirectPlay Address ID's
  2214.  *
  2215.  ****************************************************************************)
  2216.  
  2217. (* DirectPlay Address
  2218.  *
  2219.  * A DirectPlay address consists of multiple chunks of data, each tagged
  2220.  * with a GUID signifying the type of data in the chunk. The chunk also
  2221.  * has a length so that unknown chunk types can be skipped.
  2222.  *
  2223.  * The EnumAddress() function is used to parse these address data chunks.
  2224.  *)
  2225.  
  2226. (*
  2227.  * TDPAddress
  2228.  *
  2229.  * Header for block of address data elements
  2230.  *)
  2231.   PDPAddress = ^TDPAddress;
  2232.   TDPAddress = packed record
  2233.     guidDataType: TGUID;
  2234.     dwDataSize: DWORD;
  2235.   end;
  2236.  
  2237. const
  2238. (*
  2239.  * DPAID_TotalSize
  2240.  *
  2241.  * Chunk is a DWORD containing size of entire TDPAddress structure
  2242.  *)
  2243.  
  2244. // {1318F560-912C-11d0-9DAA-00A0C90A43CB}
  2245.   DPAID_TotalSize: TGUID =
  2246.   (D1: $1318F560; D2: $912C; D3: $11D0; D4: ($9D, $AA, $00, $A0, $C9, $A, $43, $CB));
  2247.  
  2248. (*
  2249.  * DPAID_ServiceProvider
  2250.  *
  2251.  * Chunk is a GUID describing the service provider that created the chunk.
  2252.  * All addresses must contain this chunk.
  2253.  *)
  2254.  
  2255. // {07D916C0-E0AF-11cf-9C4E-00A0C905425E}
  2256.   DPAID_ServiceProvider: TGUID =
  2257.   (D1: $7D916C0; D2: $E0AF; D3: $11CF; D4: ($9C, $4E, $00, $A0, $C9, $5, $42, $5E));
  2258.  
  2259. (*
  2260.  * DPAID_LobbyProvider
  2261.  *
  2262.  * Chunk is a GUID describing the lobby provider that created the chunk.
  2263.  * All addresses must contain this chunk.
  2264.  *)
  2265.  
  2266. // {59B95640-9667-11d0-A77D-0000F803ABFC}
  2267.   DPAID_LobbyProvider: TGUID =
  2268.   (D1: $59B95640; D2: $9667; D3: $11D0; D4: ($A7, $7D, $00, $00, $F8, $3, $AB, $FC));
  2269.  
  2270. (*
  2271.  * DPAID_Phone and DPAID_PhoneW
  2272.  *
  2273.  * Chunk is a string containing a phone number (i.e. "1-800-555-1212")
  2274.  * in ANSI or UNICODE format
  2275.  *)
  2276.  
  2277. // {78EC89A0-E0AF-11cf-9C4E-00A0C905425E}
  2278.   DPAID_Phone: TGUID =
  2279.   (D1: $78EC89A0; D2: $E0AF; D3: $11CF; D4: ($9C, $4E, $00, $A0, $C9, $5, $42, $5E));
  2280.  
  2281. // {BA5A7A70-9DBF-11d0-9CC1-00A0C905425E}
  2282.   DPAID_PhoneW: TGUID =
  2283.   (D1: $BA5A7A70; D2: $9DBF; D3: $11D0; D4: ($9C, $C1, $00, $A0, $C9, $5, $42, $5E));
  2284.  
  2285. (*
  2286.  * DPAID_Modem and DPAID_ModemW
  2287.  *
  2288.  * Chunk is a string containing a modem name registered with TAPI
  2289.  * in ANSI or UNICODE format
  2290.  *)
  2291.  
  2292. // {F6DCC200-A2FE-11d0-9C4F-00A0C905425E}
  2293.   DPAID_Modem: TGUID =
  2294.   (D1: $F6DCC200; D2: $A2FE; D3: $11D0; D4: ($9C, $4F, $00, $A0, $C9, $5, $42, $5E));
  2295.  
  2296. // {01FD92E0-A2FF-11d0-9C4F-00A0C905425E}
  2297.   DPAID_ModemW: TGUID =
  2298.   (D1: $1FD92E0; D2: $A2FF; D3: $11D0; D4: ($9C, $4F, $00, $A0, $C9, $5, $42, $5E));
  2299.  
  2300. (*
  2301.  * DPAID_Inet and DPAID_InetW
  2302.  *
  2303.  * Chunk is a string containing a TCP/IP host name or an IP address
  2304.  * (i.e. "dplay.microsoft.com" or "137.55.100.173") in ANSI or UNICODE format
  2305.  *)
  2306.  
  2307. // {C4A54DA0-E0AF-11cf-9C4E-00A0C905425E}
  2308.   DPAID_INet: TGUID =
  2309.   (D1: $C4A54DA0; D2: $E0AF; D3: $11CF; D4: ($9C, $4E, $00, $A0, $C9, $5, $42, $5E));
  2310.  
  2311. // {E63232A0-9DBF-11d0-9CC1-00A0C905425E}
  2312.   DPAID_INetW: TGUID =
  2313.   (D1: $E63232A0; D2: $9DBF; D3: $11D0; D4: ($9C, $C1, $00, $A0, $C9, $5, $42, $5E));
  2314.  
  2315. (*
  2316.  * DPAID_InetPort
  2317.  *
  2318.  * Chunk is the port number used for creating the apps TCP and UDP sockets.
  2319.  * WORD value (i.e. 47624)
  2320.  *)
  2321.  
  2322. // {E4524541-8EA5-11d1-8A96-006097B01411}
  2323.   DPAID_INetPort: TGUID =
  2324.   (D1: $E4524541; D2: $8EA5; D3: $11D1; D4: ($8A, $96, $00, $60, $97, $B0, $14, $11));
  2325.  
  2326. //@@BEGIN_MSINTERNAL
  2327. (*
  2328.  * DPAID_MaxMessageSize
  2329.  *
  2330.  * Tells DPLAY what the maximum allowed message size is.  Enables SPs to
  2331.  *      combat Denial of Service attacks
  2332.  *)
  2333.  
  2334.  // this terrible hack is needed so the SP can work with the Elmer build.
  2335.  // it can be removed when the MSINTERNAL stuff is removed
  2336. {$DEFINE MAXMSGSIZEGUIDDEFINED}
  2337.  
  2338. // {F5D09980-F0C4-11d1-8326-006097B01411}
  2339.   DPAID_MaxMessageSize: TGUID =
  2340.   (D1: $F5D09980; D2: $F0C4; D3: $11D1; D4: ($83, $26, $00, $60, $97, $B0, $14, $11));
  2341. //@@END_MSINTERNAL
  2342.  
  2343. (*
  2344.  * TDPComPortAddress
  2345.  *
  2346.  * Used to specify com port settings. The constants that define baud rate,
  2347.  * stop bits and parity are defined in WINBASE.H. The constants for flow
  2348.  * control are given below.
  2349.  *)
  2350.  
  2351.   DPCPA_NOFLOW = 0; // no flow control
  2352.   DPCPA_XONXOFFFLOW = 1; // software flow control
  2353.   DPCPA_RTSFLOW = 2; // hardware flow control with RTS
  2354.   DPCPA_DTRFLOW = 3; // hardware flow control with DTR
  2355.   DPCPA_RTSDTRFLOW = 4; // hardware flow control with RTS and DTR
  2356.  
  2357. type
  2358.   PDPComPortAddress = ^TDPComPortAddress;
  2359.   TDPComPortAddress = packed record
  2360.     dwComPort: DWORD; // COM port to use (1-4)
  2361.     dwBaudRate: DWORD; // baud rate (100-256k)
  2362.     dwStopBits: DWORD; // no. stop bits (1-2)
  2363.     dwParity: DWORD; // parity (none, odd, even, mark)
  2364.     dwFlowControl: DWORD; // flow control (none, xon/xoff, rts, dtr)
  2365.   end;
  2366.  
  2367. const
  2368. (*
  2369.  * DPAID_ComPort
  2370.  *
  2371.  * Chunk contains a TDPComPortAddress structure defining the serial port.
  2372.  *)
  2373.  
  2374. // {F2F0CE00-E0AF-11cf-9C4E-00A0C905425E}
  2375.   DPAID_ComPort: TGUID =
  2376.   (D1: $F2F0CE00; D2: $E0AF; D3: $11CF; D4: ($9C, $4E, $00, $A0, $C9, $5, $42, $5E));
  2377.  
  2378. (****************************************************************************
  2379.  *
  2380.  *      dplobby 1.0 obsolete definitions
  2381.  *      Included for compatibility only.
  2382.  *
  2383.  ****************************************************************************)
  2384.  
  2385.   DPLAD_SYSTEM = DPLMSG_SYSTEM;
  2386.  
  2387. implementation
  2388.  
  2389. (*==========================================================================;
  2390.  *
  2391.  *  Copyright (C) 1994-1997 Microsoft Corporation.  All Rights Reserved.
  2392.  *
  2393.  *  File:       dplay.h
  2394.  *  Content:    DirectPlay include file
  2395.  *
  2396.  ***************************************************************************)
  2397.  
  2398. function DPErrorString(Value: HResult): string;
  2399. begin
  2400.   case Value of
  2401.     CLASS_E_NOAGGREGATION: Result := 'A non-NULL value was passed for the pUnkOuter parameter in DirectPlayCreate, DirectPlayLobbyCreate, or IDirectPlayLobby2::Connect.';
  2402.     DPERR_ACCESSDENIED: Result := 'The session is full or an incorrect password was supplied.';
  2403.     DPERR_ACTIVEPLAYERS: Result := 'The requested operation cannot be performed because there are existing active players.';
  2404.     DPERR_ALREADYINITIALIZED: Result := 'This object is already initialized.';
  2405.     DPERR_APPNOTSTARTED: Result := 'The application has not been started yet.';
  2406.     DPERR_AUTHENTICATIONFAILED: Result := 'The password or credentials supplied could not be authenticated.';
  2407.     DPERR_BUFFERTOOLARGE: Result := 'The data buffer is too large to store.';
  2408.     DPERR_BUSY: Result := 'A message cannot be sent because the transmission medium is busy.';
  2409.     DPERR_BUFFERTOOSMALL: Result := 'The supplied buffer is not large enough to contain the requested data.';
  2410.     DPERR_CANTADDPLAYER: Result := 'The player cannot be added to the session.';
  2411.     DPERR_CANTCREATEGROUP: Result := 'A new group cannot be created.';
  2412.     DPERR_CANTCREATEPLAYER: Result := 'A new player cannot be created.';
  2413.     DPERR_CANTCREATEPROCESS: Result := 'Cannot start the application.';
  2414.     DPERR_CANTCREATESESSION: Result := 'A new session cannot be created.';
  2415.     DPERR_CANTLOADCAPI: Result := 'No credentials were supplied and the CryptoAPI package (CAPI) to use for cryptography services cannot be loaded.';
  2416.     DPERR_CANTLOADSECURITYPACKAGE: Result := 'The software security package cannot be loaded.';
  2417.     DPERR_CANTLOADSSPI: Result := 'No credentials were supplied and the software security package (SSPI) that will prompt for credentials cannot be loaded.';
  2418.     DPERR_CAPSNOTAVAILABLEYET: Result := 'The capabilities of the DirectPlay object have not been determined yet. This error will occur if the DirectPlay object is implemented on a connectivity solution that requires polling to determine available bandwidth and latency.';
  2419.     DPERR_CONNECTING: Result := 'The method is in the process of connecting to the network. The application should keep calling the method until it returns DP_OK, indicating successful completion, or it returns a different error.';
  2420.     DPERR_ENCRYPTIONFAILED: Result := 'The requested information could not be digitally encrypted. Encryption is used for message privacy. This error is only relevant in a secure session.';
  2421.     DPERR_EXCEPTION: Result := 'An exception occurred when processing the request.';
  2422.     DPERR_GENERIC: Result := 'An undefined error condition occurred.';
  2423. //    DPERR_INVALIDCREDENTIALS: Result := 'The credentials supplied (as to IDirectPlay3::SecureOpen) were not valid.';
  2424.     DPERR_INVALIDFLAGS: Result := 'The flags passed to this method are invalid.';
  2425.     DPERR_INVALIDGROUP: Result := 'The group ID is not recognized as a valid group ID for this game session.';
  2426.     DPERR_INVALIDINTERFACE: Result := 'The interface parameter is invalid.';
  2427.     DPERR_INVALIDOBJECT: Result := 'The DirectPlay object pointer is invalid.';
  2428.     DPERR_INVALIDPARAMS: Result := 'One or more of the parameters passed to the method are invalid.';
  2429.     DPERR_INVALIDPASSWORD: Result := 'An invalid password was supplied when attempting to join a session that requires a password.';
  2430.     DPERR_INVALIDPLAYER: Result := 'The player ID is not recognized as a valid player ID for this game session.';
  2431.     DPERR_LOGONDENIED: Result := 'The session could not be opened because credentials are required and either no credentials were supplied or the credentials were invalid.';
  2432.     DPERR_NOCAPS: Result := 'The communication link that DirectPlay is attempting to use is not capable of this function.';
  2433.     DPERR_NOCONNECTION: Result := 'No communication link was established.';
  2434.     DPERR_NOINTERFACE: Result := 'The interface is not supported.';
  2435.     DPERR_NOMESSAGES: Result := 'There are no messages in the receive queue.';
  2436.     DPERR_NONAMESERVERFOUND: Result := 'No name server (host) could be found or created. A host must exist to create a player.';
  2437.     DPERR_NONEWPLAYERS: Result := 'The session is not accepting any new players.';
  2438.     DPERR_NOPLAYERS: Result := 'There are no active players in the session.';
  2439.     DPERR_NOSESSIONS: Result := 'There are no existing sessions for this game.';
  2440.     DPERR_NOTLOBBIED: Result := 'Returned by the IDirectPlayLobby2::Connect method if the application was not started by using the IDirectPlayLobby2::RunApplication method or if there is no DPLCONNECTION structure currently initialized for this DirectPlayLobby object.';
  2441.     DPERR_NOTLOGGEDIN: Result := 'An action cannot be performed because a player or client application is not logged in. Returned by the IDirectPlay3::Send method when the client application tries to send a secure message without being logged in.';
  2442.     DPERR_OUTOFMEMORY: Result := 'There is insufficient memory to perform the requested operation.';
  2443.     DPERR_PLAYERLOST: Result := 'A player has lost the connection to the session.';
  2444.     DPERR_SENDTOOBIG: Result := 'The message being sent by the IDirectPlay3::Send method is too large.';
  2445.     DPERR_SESSIONLOST: Result := 'The connection to the session has been lost.';
  2446.     DPERR_SIGNFAILED: Result := 'The requested information could not be digitally signed. Digital signatures are used to establish the authenticity of messages.';
  2447.     DPERR_TIMEOUT: Result := 'The operation could not be completed in the specified time.';
  2448.     DPERR_UNAVAILABLE: Result := 'The requested function is not available at this time.';
  2449.     DPERR_UNINITIALIZED: Result := 'The requested object has not been initialized.';
  2450.     DPERR_UNKNOWNAPPLICATION: Result := 'An unknown application was specified.';
  2451.     DPERR_UNSUPPORTED: Result := 'The function is not available in this implementation. Returned from IDirectPlay3::GetGroupConnectionSettings and IDirectPlay3::SetGroupConnectionSettings if they are called from a session that is not a lobby session.';
  2452.     DPERR_USERCANCEL: Result := 'Can be returned in two ways. 1) The user canceled the connection process during a call to the IDirectPlay3::Open method. 2) The user clicked Cancel in one of the DirectPlay service provider dialog boxes during a call to IDirectPlay3::EnumSessions.';
  2453.   else Result := 'Unrecognized Error';
  2454.   end;
  2455. end;
  2456.  
  2457. function IsNTandDelphiRunning : boolean;
  2458. var
  2459.   OSVersion  : TOSVersionInfo;
  2460.   AppName    : array[0..255] of char;
  2461. begin
  2462.   OSVersion.dwOsVersionInfoSize := sizeof(OSVersion);
  2463.   GetVersionEx(OSVersion);
  2464.   // Not running in NT or program is not Delphi itself ?
  2465.   AppName[0] := #0;
  2466.   lstrcat(AppName, PChar(ParamStr(0)));  // ParamStr(0) = Application.ExeName
  2467.   {$IFDEF UNICODE}
  2468.   CharUpperBuff(AppName, High(AppName) + 1);
  2469.   {$ELSE}
  2470.   CharUpperBuff(AppName, SizeOf(AppName));
  2471.   {$ENDIF}
  2472.   result := ( (OSVersion.dwPlatformID = VER_PLATFORM_WIN32_NT) and
  2473.               (Pos('DELPHI32.EXE', AppName) = Length(AppName) - Length('DELPHI32.EXE') + 1) );
  2474. end;
  2475.  
  2476. initialization
  2477.   begin
  2478.     if not IsNTandDelphiRunning then
  2479.     begin
  2480.       DPlayDLL := LoadLibrary('DPlayX.dll');
  2481.  
  2482.       DirectPlayEnumerateA := GetProcAddress(DPlayDLL, 'DirectPlayEnumerateA');
  2483.       DirectPlayEnumerateW := GetProcAddress(DPlayDLL, 'DirectPlayEnumerateW');
  2484. {$IFDEF UNICODE}
  2485.       DirectPlayEnumerate := DirectPlayEnumerateW;
  2486. {$ELSE}
  2487.       DirectPlayEnumerate := DirectPlayEnumerateA;
  2488. {$ENDIF}
  2489.  
  2490.       DirectPlayCreate := GetProcAddress(DPlayDLL, 'DirectPlayCreate');
  2491.  
  2492. //  File:       dplay.h
  2493.  
  2494.       DirectPlayLobbyCreateW := GetProcAddress(DPlayDLL, 'DirectPlayLobbyCreateW');
  2495.       DirectPlayLobbyCreateA := GetProcAddress(DPlayDLL, 'DirectPlayLobbyCreateA');
  2496. {$IFDEF UNICODE}
  2497.       DirectPlayLobbyCreate := DirectPlayLobbyCreateW;
  2498. {$ELSE}
  2499.       DirectPlayLobbyCreate := DirectPlayLobbyCreateA;
  2500. {$ENDIF}
  2501.  
  2502.     end;
  2503.   end;
  2504.  
  2505. finalization
  2506.   begin
  2507.     if DPlayDLL <> 0 then FreeLibrary(DPlayDLL);
  2508.   end;
  2509.  
  2510. end.
  2511.