   DirectPlay Client Initialization
  I've been trying to get DirectPlay to work recently and thanks to help from here I have the server 100% working. Now on to the client. I'm currently using the below code (roughly copied from Role Playing Games w/ DX) but IDirectPlay8Client::Connect always returns E_INVALIDARG and I have no clue why! Does anyone see the problem with this:? IDirectPlay8Client *StartClientServer(char* szPlayerName, char* szSessionName, char* szPassword, char* szIPAddress, DWORD dwPort){IDirectPlay8Client *pDPClient;DPN_SERVICE_PROVIDER_INFO* pSP = NULL;IDirectPlay8Address *pDPAddress, *pDPHostAddress;DPN_APPLICATION_DESC dpad;DPN_PLAYER_INFO dppi;WCHAR wszSessionName[256];WCHAR wszPassword[256];WCHAR wszIPAddress[256];WCHAR wszPlayerName[256];CoCreateInstance(CLSID_DirectPlay8Client, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Client, (void**)&pDPClient);pDPClient->Initialize(NULL, DPClientMessageHandler, NULL);CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (void**)&pDPAddress);CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (void**)&pDPHostAddress);pDPAddress->SetSP(&CLSID_DP8SP_TCPIP);pDPHostAddress->SetSP(&CLSID_DP8SP_TCPIP);mbstowcs(wszIPAddress, szIPAddress, strlen(szIPAddress)+1);pDPHostAddress->AddComponent(DPNA_KEY_HOSTNAME, wszIPAddress, (wcslen(wszIPAddress)+1)*sizeof(WCHAR), DPNA_DATATYPE_STRING);pDPHostAddress->AddComponent(DPNA_KEY_PORT, &dwPort, sizeof(DWORD), DPNA_DATATYPE_DWORD);ZeroMemory(&dppi, sizeof(DPN_PLAYER_INFO));dppi.dwSize = sizeof(DPN_PLAYER_INFO);dppi.dwInfoFlags = DPNINFO_NAME | DPNINFO_DATA;mbstowcs(wszPlayerName, szPlayerName, strlen(szPlayerName+1));dppi.pwszName = wszPlayerName;pDPClient->SetClientInfo(&dppi, NULL, NULL, DPNSETCLIENTINFO_SYNC);ZeroMemory(&dpad, sizeof(DPN_APPLICATION_DESC));dpad.dwSize = sizeof(DPN_APPLICATION_DESC);dpad.guidApplication = AppGuid;dpad.dwFlags = DPNSESSION_CLIENT_SERVER;mbstowcs(wszSessionName, szSessionName, strlen(szSessionName)+1);dpad.pwszSessionName = wszSessionName;if(szPassword != NULL){mbstowcs(wszPassword, szPassword, strlen(szPassword)+1);dpad.pwszPassword = wszPassword;dpad.dwFlags |= DPNSESSION_REQUIREPASSWORD;}HRESULT hr = pDPClient->Connect(&dpad, pDPHostAddress, pDPAddress, NULL, NULL, NULL, 0, NULL, NULL, DPNCONNECT_SYNC | DPNENUMHOSTS_OKTOQUERYFORADDRESSING);if(FAILED(hr))cout << "Connect: " << hr << endl;pDPAddress->Release();pDPHostAddress->Release();return pDPClient;}[edited by - ms291052 on February 5, 2004 9:01:58 PM]
  bump 