Subversion Repositories spacemission

Rev

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