1 | // Helper function - Creates/Joins a session |
2 | static HRESULT OpenSession() |
3 | { |
4 | HRESULT hr; |
5 | DPSESSIONDESC sessionDesc; |
6 | ZeroMemory(&sessionDesc, sizeof(DPSESSIONDESC)); |
7 | if(joinSession) //To join a session |
8 | sessionDesc.dwFlags = DPOPEN_OPENSESSION; |
9 | else |
10 | { |
11 | // To host a new session. |
12 | sessionDesc.dwFlags = DPOPEN_CREATESESSION; |
13 | strcpy(sessionDesc.szSessionName, sessionName); |
14 | sessionDesc.dwMaxPlayers = 10; |
15 | } |
16 | sessionDesc.dwSize = sizeof(DPSESSIONDESC); |
17 | sessionDesc.guidSession = sessionGUID; |
18 | sessionDesc.dwSession = 2; |
19 | hr = lpDirectPlay1->Open(&sessionDesc); |
20 | if(FAILED(hr)) |
21 | ::MessageBox(NULL,"Open Failed", "HelloWorld", MB_OK); |
22 | return(hr); |
23 | } |
24 | OpenSession(): |
25 | Creates or joins a session |