Subversion Repositories spacemission

Rev

Rev 21 | Details | Compare with Previous | Last modification | View Log | RSS feed

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