- DirectX9用Tool「Dx9Info」はDirectX9.0bの機能を利用してビデオカードなどの情報を取得、HTMLへの書き出しを行うツールです。
そのため動作には「DirectX 9.0b以降」が必須となります。
また、私が確認している動作OSは「WindowsXP」と「Windows2000 SP4」のみとなっています。
- 吐き出す情報の中にはDirectXの機能のみでは取得できない「OSのバージョン情報」などもありますが、Win32APIで行っています。
Windows環境であれば機能するものと思われます。
- インクルードするヘッダーなど
#pragma warning(disable: 4204) // ワーニングメッセージの抑制 デバックリンクエラー
#ifdef _DEBUG
# pragma comment(lib, "d3d9.lib")
# pragma comment(lib, "d3dx9d.lib")
# pragma comment(lib, "DxErr9.lib")
# pragma comment(lib, "version.lib")
#else
# pragma comment(lib, "d3d9.lib")
# pragma comment(lib, "d3dx9.lib")
# pragma comment(lib, "version.lib")
#endif
# pragma comment(lib, "dxguid.lib")
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <windows.h> // Windows標準ヘッダー
#include <stdio.h> // 標準入出力ヘッダー
#include <cstdlib>
#include <crtdbg.h>
#else
#include <windows.h> // Windows標準ヘッダー
#include <stdio.h> // 標準入出力ヘッダー
#endif
#include <d3d9.h> // Direct3D9用ヘッダー
#include <D3DX9.h> // Direct3DX9用ヘッダー
#ifdef _DEBUG
#include <DxErr9.h> // DirectX9 Err用ヘッダー
#endif
private:
// DirectX開放専用定数
#define Release(p) if ((p) != NULL) p->Release(), (p) = NULL
private:
// Direct3D9 初期化に使用
LPDIRECT3D9 m_pD3D;
LPDIRECT3DDEVICE9 m_pd3dDevice;
D3DPRESENT_PARAMETERS m_d3dpp;
////////////////////////////////////////////////////////////////////////////////
// Direct3D情報の取得
// HWND は後で使用するかもしれないので念のため
////////////////////////////////////////////////////////////////////////////////
bool Cdx9info::GetD3DInfo(HWND hWnd)
{
m_pD3D = NULL;
m_pd3dDevice = NULL;
g_iAdapterCount = 0;
m_d3dType = D3DDEVTYPE_HAL;
g_Dx9Info = NULL;
// IDIRECT9の初期化
m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
if(m_pD3D == NULL)
{
// DirectX9初期化そのものに失敗
return false;
}
// パソコンに搭載されたビデオカードの枚数を取得
g_iAdapterCount = m_pD3D->GetAdapterCount();
// 枚数にあわせて構造体を確保
g_Dx9Info = new DX9INFO[g_iAdapterCount];
// ビデオカードの枚数分能力をチェックする
for(int i = 0; i < g_iAdapterCount; i++ )
{
// 物理的なディスプレイ アダプタを取得
GetAdapterIndentiFier9(i, &g_Dx9Info[i].dx9AdapterIndentiFier);
// デバイス固有の情報を取得する
GetDeviceCaps(i, &g_Dx9Info[i].dx9DeviceCaps);
// 使用可能な解像度などを取得
GetD3dDispModeFmt(i, &g_Dx9Info[i].dx9DispModeFmt);
// HAL とBackBUFFERを調べる
// フルスクリーン
GetD3dDispHalFmt(i, false, &g_Dx9Info[i].dx9HalDispFormatFull);
// Window
GetD3dDispHalFmt(i, true, &g_Dx9Info[i].dx9HalDispFormatWindow);
// 使用アダプタの使用可能フォーマットを確認する
// CheckDeviceFormat
// フルスクリーン
GetD3dFmt(i, &g_Dx9Info[i].dx9D3dFmtFull, g_Dx9Info[i].dx9HalDispFormatFull);
GetD3dDepthStencilFmt(i, &g_Dx9Info[i].dx9D3dDepthStencilFmtFull,
g_Dx9Info[i].dx9HalDispFormatFull);
GetD3dMultiSampleType(i, false, &g_Dx9Info[i].dx9D3dMultiSampleFull,
g_Dx9Info[i].dx9HalDispFormatFull);
// Window
GetD3dFmt(i, &g_Dx9Info[i].dx9D3dFmtWindow, g_Dx9Info[i].dx9HalDispFormatFull);
GetD3dDepthStencilFmt(i, &g_Dx9Info[i].dx9D3dDepthStencilFmtWindow,
g_Dx9Info[i].dx9HalDispFormatFull);
GetD3dMultiSampleType(i, true, &g_Dx9Info[i].dx9D3dMultiSampleWindow,
g_Dx9Info[i].dx9HalDispFormatWindow);
}
// IDirectX9を開放する
if(m_pD3D != NULL)
{
Release(m_pD3D);
m_pD3D = NULL;
}
return true;
}