2013年6月22日土曜日

ヘッダー部の属性取得;GetAttributeByName

とりあえずメモ

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
#include <stdio.h>//printf とかで必要
#include<windows.h>//MessageBox とかで必要
 
#include <wmsdk.h>
#pragma comment(lib, "wmvcore.lib")
 
void main(void)
{
 
 IWMMetadataEditor * pEditor = NULL;
 IWMHeaderInfo * pHeaderInfo = NULL;
 
 HRESULT hr = S_FALSE;
 
 hr = WMCreateEditor(&pEditor);
 
 hr = pEditor->Open(L"G:\\sampleMovie\\sample.wmv");
 
 pEditor->QueryInterface(IID_IWMHeaderInfo, (void**) &pHeaderInfo);
 
 WMT_ATTR_DATATYPE attType;
 WORD streamNum = 1;
 WORD cbValue = 0;
 
 //文字列の適切なサイズを取得
 hr = pHeaderInfo->GetAttributeByName(&streamNum,
  g_wszDeviceConformanceTemplate, &attType, NULL, &cbValue);
 
 WCHAR *pbValue = (WCHAR *) new BYTE[ cbValue ];  
 if( ! pbValue )  
 {  
  printf("割り当て失敗\n");
 }  
 
 hr = pHeaderInfo->GetAttributeByName(&streamNum,
  g_wszDeviceConformanceTemplate, &attType, (BYTE *) pbValue, &cbValue);
 
 printf("%S\n",pbValue);//L1と出力
 
 MessageBox(0,0,TEXT("OK"),0);
}

0 件のコメント:

コメントを投稿