source: trunk/src/dplay/dplay.cpp@ 22012

Last change on this file since 22012 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 5.3 KB
Line 
1/* $Id: dplay.cpp,v 1.2 1999-10-04 09:55:56 sandervl Exp $ */
2
3/* Direct Play 3 and Direct Play Lobby 2 Implementation
4 *
5 * Copyright (C) 1999 Patrick Haller <phaller@gmx.net>
6 *
7 */
8
9#include <odin.h>
10#include <os2win.h>
11
12#define CINTERFACE
13
14#include "winerror.h"
15#include "winnt.h"
16#include "winreg.h"
17#include "dplay.h"
18#include "dplobby.h"
19#include "heap.h"
20#include "debugtools.h"
21
22#include <odinwrap.h>
23#include <heapstring.h>
24#include <misc.h>
25
26ODINDEBUGCHANNEL(DPLAY)
27
28
29/***************************************************************************
30 * DirectPlayEnumerateA (DPLAYX.2)
31 *
32 * The pointer to the structure lpContext will be filled with the
33 * appropriate data for each service offered by the OS. These services are
34 * not necessarily available on this particular machine but are defined
35 * as simple service providers under the "Service Providers" registry key.
36 * This structure is then passed to lpEnumCallback for each of the different
37 * services.
38 *
39 * This API is useful only for applications written using DirectX3 or
40 * worse. It is superceeded by IDirectPlay3::EnumConnections which also
41 * gives information on the actual connections.
42 *
43 * defn of a service provider:
44 * A dynamic-link library used by DirectPlay to communicate over a network.
45 * The service provider contains all the network-specific code required
46 * to send and receive messages. Online services and network operators can
47 * supply service providers to use specialized hardware, protocols, communications
48 * media, and network resources.
49 *
50 * TODO: Allocate string buffer space from the heap (length from reg)
51 * Pass real device driver numbers...
52 * Get the GUID properly...
53 */
54HRESULT WINAPI DirectPlayEnumerateA( LPDPENUMDPCALLBACKA lpEnumCallback,
55 LPVOID lpContext )
56{
57
58 HKEY hkResult;
59 LPCSTR searchSubKey = "SOFTWARE\\Microsoft\\DirectPlay\\Service Providers";
60 LPCSTR guidDataSubKey = "Guid";
61 LPCSTR majVerDataSubKey= "dwReserved1";
62 DWORD dwIndex, sizeOfSubKeyName=50;
63 char subKeyName[51];
64
65 TRACE(": lpEnumCallback=%p lpContext=%p\n", lpEnumCallback, lpContext );
66
67 if( !lpEnumCallback )
68 {
69 return DPERR_INVALIDPARAMS;
70 }
71
72 /* Need to loop over the service providers in the registry */
73 if( RegOpenKeyExA( HKEY_LOCAL_MACHINE, searchSubKey,
74 0, KEY_ENUMERATE_SUB_KEYS, &hkResult ) != ERROR_SUCCESS )
75 {
76 /* Hmmm. Does this mean that there are no service providers? */
77 ERR(": no service providers?\n");
78 return DP_OK;
79 }
80
81 /* Traverse all the service providers we have available */
82 for( dwIndex=0;
83 RegEnumKeyA( hkResult, dwIndex, subKeyName, sizeOfSubKeyName ) !=
84 ERROR_NO_MORE_ITEMS;
85 ++dwIndex )
86 {
87 HKEY hkServiceProvider;
88 GUID serviceProviderGUID;
89 DWORD returnTypeGUID, returnTypeReserved1, sizeOfReturnBuffer=50;
90 char returnBuffer[51];
91 DWORD majVersionNum /*, minVersionNum */;
92 LPWSTR lpWGUIDString;
93
94 TRACE(" this time through: %s\n", subKeyName );
95
96 /* Get a handle for this particular service provider */
97 if( RegOpenKeyExA( hkResult, subKeyName, 0, KEY_QUERY_VALUE,
98 &hkServiceProvider ) != ERROR_SUCCESS )
99 {
100 ERR(": what the heck is going on?\n" );
101 continue;
102 }
103
104 /* Get the GUID, Device major number and device minor number
105 * from the registry.
106 */
107 if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
108 NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
109 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
110 {
111 ERR(": missing GUID registry data members\n" );
112 continue;
113 }
114
115 /* FIXME: Check return types to ensure we're interpreting data right */
116 lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
117 CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
118 HeapFree( GetProcessHeap(), 0, lpWGUIDString );
119
120 sizeOfReturnBuffer = 50;
121
122 if( RegQueryValueExA( hkServiceProvider, majVerDataSubKey,
123 NULL, &returnTypeReserved1, (LPBYTE)returnBuffer,
124 &sizeOfReturnBuffer ) != ERROR_SUCCESS )
125 {
126 ERR(": missing dwReserved1 registry data members\n") ;
127 continue;
128 }
129 /* FIXME: This couldn't possibly be right...*/
130 majVersionNum = GET_DWORD( returnBuffer );
131
132 /* The enumeration will return FALSE if we are not to continue */
133 if( !lpEnumCallback( &serviceProviderGUID , subKeyName,
134 majVersionNum, (DWORD)0, lpContext ) )
135 {
136 WARN("lpEnumCallback returning FALSE\n" );
137 break;
138 }
139 }
140
141 return DP_OK;
142
143}
144
145/***************************************************************************
146 * DirectPlayEnumerateW (DPLAYX.3)
147 *
148 */
149HRESULT WINAPI DirectPlayEnumerateW( LPDPENUMDPCALLBACKW lpEnumCallback, LPVOID lpContext )
150{
151
152 FIXME(":stub\n");
153
154 return DPERR_OUTOFMEMORY;
155
156}
157
158/***************************************************************************
159 * DirectPlayCreate (DPLAYX.1) (DPLAY.1)
160 *
161 */
162HRESULT WINAPI DirectPlayCreate
163( LPGUID lpGUID, LPDIRECTPLAY2 *lplpDP, IUnknown *pUnk)
164{
165 //@@@PH stub
166 FIXME("lpGUID=%p lplpDP=%p pUnk=%p\n", lpGUID,lplpDP,pUnk);
167
168 if( pUnk != NULL )
169 {
170 /* Hmmm...wonder what this means! */
171 ERR("What does a NULL here mean?\n" );
172 return DPERR_OUTOFMEMORY;
173 }
174
175
176 /* Unknown interface type */
177 return DPERR_NOINTERFACE;
178
179}
180
Note: See TracBrowser for help on using the repository browser.