// // Function: main // // Description: // The main function which loads Winsock, parses the command line, // and initiates either the client or server routine depending // on the parameters passed. // int main(int argc, char **argv) { WSADATA wsd; ValidateArgs(argc, argv); if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { printf("WSAStartup() failed: %d\n", GetLastError()); return -1; } // Check to see if the role of the application is to enumerate local // adapters // if (bEnumerate) EnumerateAdapters(); else { if (bServer) // Act as server Server(); else // Act as client Client(); } closesocket(sock); closesocket(newsock); WSACleanup(); return 0; }
//----------------------------------------------------------------------------- // Name : Enumerate () // Desc : This function must be called first to enumerate all available // devices, adapters, modes and formats, prior to initialization. //----------------------------------------------------------------------------- HRESULT CD3DInitialize::Enumerate( LPDIRECT3D9 pD3D ) { HRESULT hRet; // Store the D3D Object m_pD3D = pD3D; if ( !m_pD3D ) return E_FAIL; // AddRef on the D3D9 Object so we can auto cleanup m_pD3D->AddRef(); // Enumerate the adapters if ( FAILED( hRet = EnumerateAdapters() ) ) return hRet; // Success! return S_OK; }