/*
空のCLRプロジェクト
*/
#include <stdio.h> //printf とかで必要
#include <wmsdk.h> //HRESULT とかで必要
#pragma comment(lib, "wmvcore.lib") //IWMMetadataEditor とかで必要
#pragma comment ( lib, "ole32.lib" )//CoInitialize で必要
using namespace System;//Console::ReadLine()で必要
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(x) \
if(x != NULL) \
{ \
x->Release(); \
x = NULL; \
}
#endif
int main(void)
{
HRESULT hr = S_OK;
IWMProfileManager* pProfileMgr = NULL;
IWMProfileManager2* pProfileMgr2 = NULL;
WMT_VERSION profileVersion;
// Create a profile manager object.
// プロファイルマネージャオブジェクトを作成します。
hr = WMCreateProfileManager(&pProfileMgr);
if(FAILED(hr))
{
printf("Could not create a profile manager object.");
return 0;
}
// Get the IWMProfileManager2 interface.
// IWMProfileManager2インタフェースを取得します。
hr = pProfileMgr->QueryInterface(IID_IWMProfileManager2,
(void**) &pProfileMgr2);
if(FAILED(hr))
{
printf("Could not get the IWMProfileManager2 interface.");
SAFE_RELEASE(pProfileMgr);
return 0;
}
// Release the old interface.
// 古いインターフェースを解放します。
SAFE_RELEASE(pProfileMgr);
// Set the system profile version to 8.
// システムプロファイルをバージョン8に設定
profileVersion = WMT_VER_8_0;
hr = pProfileMgr2->SetSystemProfileVersion(profileVersion);
if(FAILED(hr))
{
printf("Could not change profile version.");
printf("\nError code: 0x%X\n", hr);
SAFE_RELEASE(pProfileMgr2);
return 0;
}
//------------------------------------------------------------------------------
DWORD profileCount = 0;
DWORD length = 0;
// char szName[256];
// char szDesc[256];
// システムプロファイルの数を取得
hr = pProfileMgr2->GetSystemProfileCount(&profileCount);
printf("*** Total Count: %d ***\n", profileCount);
for (int i = 0; i < (int)profileCount; ++i)
{
printf(" --------- No: %d -----------------\r\n", i);
IWMProfile * pProfile = NULL;
hr = pProfileMgr2->LoadSystemProfile(i, &pProfile);
if (FAILED(hr))
{
printf("%2d: Failed to Load System Profile!hr=0x%x\n", i, hr);
return FALSE;
}
hr = pProfile->GetName(NULL, &length);
WCHAR *wszName = new WCHAR[length + 1];
hr = pProfile->GetName(wszName, &length);
//WideCharToMultiByte(CP_ACP, 0, wszName, -1, szName,256, NULL, NULL);
printf("neme:%S\r\n", wszName);
// Profile
hr = pProfile->GetDescription(NULL, &length);
WCHAR *wszDesc = new WCHAR[length + 1];
hr = pProfile->GetDescription(wszDesc, &length);
printf("Profile:%S\r\n", wszDesc);
//WideCharToMultiByte(CP_ACP, 0, wszDesc, -1, szDesc, 256,NULL, NULL);
}
printf("-------------プログラム終了----------------");
Console::ReadLine();//入力待-ウインドウ維持
}
2013年6月26日水曜日
システムプロファイルの数を取得:IWMProfileManager::GetSystemProfileCount
登録:
コメントの投稿 (Atom)

0 件のコメント:
コメントを投稿