2013年6月26日水曜日

システムプロファイルの言語を取得:IWMProfileManagerLanguage::GetUserLanguageID

To Load a System Profile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
空の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;
 
 IWMProfileManagerLanguage* pProfileMgrLang = NULL;
 
 // Create a profile manager object.
 // プロファイルマネージャオブジェクトを作成します。
 hr = WMCreateProfileManager(&pProfileMgr);
 if(FAILED(hr))
 {
  printf("Could not create a profile manager object.");
  return 0;
 }
 
 // Get the profile manager language interface.
 // 言語インターフェイスプロファイルマネージャーの取得
 pProfileMgr->QueryInterface(IID_IWMProfileManagerLanguage, (void**)&pProfileMgrLang);
 
 if(FAILED(hr))
 {
  printf("Couldn't get IWMProfileManagerLanguage.\n");
  SAFE_RELEASE(pProfileMgrLang);
  return hr;
 }
 
 // Retrieve the current language (as a LANGID value)
 // 現在の言語を取得
 WORD wLangID = 0;
 hr = pProfileMgrLang->GetUserLanguageID(&wLangID);
 if(FAILED(hr))
 {
  printf("Could not get the current language.\n");
  SAFE_RELEASE(pProfileMgrLang);
  return hr;
 }
 
 printf("The current language ID is 0x%X\n", wLangID);//English – United States (0x0409)
 
 
 SAFE_RELEASE(pProfileMgrLang);
 
 printf("-------------プログラム終了----------------");
 
 Console::ReadLine();//入力待-ウインドウ維持
}


0 件のコメント:

コメントを投稿