// Helper function - Creates/Joins a session |
static HRESULT OpenSession() |
{ |
HRESULT hr; |
DPSESSIONDESC sessionDesc; |
ZeroMemory(&sessionDesc, sizeof(DPSESSIONDESC)); |
if(joinSession) //To join a session |
sessionDesc.dwFlags = DPOPEN_OPENSESSION; |
else |
{ |
// To host a new session. |
sessionDesc.dwFlags = DPOPEN_CREATESESSION; |
strcpy(sessionDesc.szSessionName, sessionName); |
sessionDesc.dwMaxPlayers = 10; |
} |
sessionDesc.dwSize = sizeof(DPSESSIONDESC); |
sessionDesc.guidSession = sessionGUID; |
sessionDesc.dwSession = 2; |
hr = lpDirectPlay1->Open(&sessionDesc); |
if(FAILED(hr)) |
::MessageBox(NULL,"Open Failed", "HelloWorld", MB_OK); |
return(hr); |
} |
OpenSession(): |
Creates or joins a session |