個人的な記録をメモ的に残しています。
正確さは保障出来ません。未整理
開発環境は
vista 32bit
2013年5月くらいにwindows 8 64bit を入れた。
Visual C++ 2010 Express
ただいま勉強中
Visual C++ 2010 Express
2011年からVisual C++ Expressを始めた記録
2020年1月12日日曜日
2013年6月29日土曜日
ファイルの属性(プロパティー)の取得:Shell32
ソリューションエクスプローラからプロジェクトを選択して、
右クリックして、参照を選択して、COMタブを選択して、
Microsoft Shell Controls And Automationを追加する
すべての属性取得
値のある属性のみ取得
右クリックして、参照を選択して、COMタブを選択して、
Microsoft Shell Controls And Automationを追加する
/*
空のCLRプロジェクト
音楽ファイルの長さを取得
*/
using namespace System;//Console::ReadLine()で必要
using namespace Shell32;//ShellClass Folder FolderItem とかで必要
[STAThread]//Shell32::Folder ^f = shell->NameSpace(dir);で出る例外対策
void main(){
String ^dir = "G:\\sampleMovie"; // MP3ファイルのあるディレクトリ
String ^file = "Amanda.wma";
ShellClass ^shell = gcnew ShellClass();
Folder ^f = shell->NameSpace(dir);
FolderItem ^item = f->ParseName(file);
Console::WriteLine(f->GetDetailsOf(item, 27)); // 長さ win8の場合
Console::ReadLine();//入力待-ウインドウ維持
}
すべての属性取得
/*
空のCLRプロジェクト
ファイルの属性をすべて表示・取得
*/
#include <stdio.h> //NULL とかで必要
using namespace System;//Console::ReadLine()で必要
using namespace Shell32;//ShellClass Folder FolderItem とかで必要
[STAThread]//Shell32::Folder ^f = shell->NameSpace(dir);で出る例外対策
void main(){
String ^dir = "G:\\sampleMovie"; // MP3ファイルのあるディレクトリ
String ^file = "Amanda.wma";
ShellClass ^shell = gcnew ShellClass();
Folder ^f = shell->NameSpace(dir);
FolderItem ^item = f->ParseName(file);
int i = 0;
String^ name = f->GetDetailsOf(NULL, i);
while ( !String::IsNullOrEmpty( name ) )
{
// 属性名 表示
Console::WriteLine("{0,3} : {1}", i, name);
i++;
name = f->GetDetailsOf(NULL, i);
}
Console::ReadLine();//入力待-ウインドウ維持
}
値のある属性のみ取得
/*
空のCLRプロジェクト
ファイルの属性で値のあるものを表示・取得
*/
#include <stdio.h> //NULL とかで必要
using namespace System;//Console::ReadLine()で必要
using namespace Shell32;//ShellClass Folder FolderItem とかで必要
[STAThread]//Shell32::Folder ^f = shell->NameSpace(dir);で出る例外対策
void main(){
String ^dir = "G:\\sampleMovie"; // MP3ファイルのあるディレクトリ
String ^file = "Amanda.wma";
ShellClass ^shell = gcnew ShellClass();
Folder ^f = shell->NameSpace(dir);
FolderItem ^item = f->ParseName(file);
int i = 0;
String^ name = f->GetDetailsOf(NULL, i);
while ( !String::IsNullOrEmpty( name ) )
{
// 属性の値を取得
String^ value = f->GetDetailsOf(item, i);
//値があれば表示
if (!String::IsNullOrEmpty( value ))
{
Console::WriteLine("{0,3} : {1}", i, name);//属性名
Console::WriteLine("\t{0}", value);//値
}
i++;
name = f->GetDetailsOf(NULL, i);
}
Console::ReadLine();//入力待-ウインドウ維持
}
2013年6月26日水曜日
ストリーム数を調べる:IWMProfile::GetStreamCount
未整理
/*
空の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;
IWMProfile * pProfile= NULL;; //
IWMSyncReader * mSyncReader;
hr = WMCreateSyncReader(NULL, 0, &mSyncReader);
// Create a profile manager object.
// プロファイルマネージャオブジェクトを作成します。
hr = mSyncReader->Open(L"G:\\sampleMovie\\sample.mp3");
if (FAILED(hr))
{
printf("-------------失敗----------------");
return E_FAIL;
}
hr = mSyncReader->QueryInterface(IID_IWMProfile,(void**)&pProfile);
DWORD dwStreamCount = 0;
hr = pProfile->GetStreamCount(&dwStreamCount);
for (DWORD dwIndex = 0; dwIndex < dwStreamCount; dwIndex++)
{
printf("%d-------------\r\n",dwIndex);
IWMStreamConfig *pConfig = NULL;
hr = pProfile->GetStream(dwIndex, &pConfig);
if (FAILED(hr))
{
printf("%d------失敗-------");
printf("Could not get the stream: (hr=0x%08x)\n", hr);
return hr;
}
GUID guid = GUID_NULL;
hr = pConfig->GetStreamType(&guid);
if (FAILED(hr))
{
printf("------失敗1-------");
printf("Could not get the stream type: (hr=0x%08x)\n", hr);
return hr;
}
else
{
if (WMMEDIATYPE_Video == guid)
{
printf("WMMEDIATYPE_Video\r\n");
}
else if (WMMEDIATYPE_Audio == guid)
{
printf("WMMEDIATYPE_Audioo\r\n");
}
else if (WMMEDIATYPE_Script == guid)
{
printf("WMMEDIATYPE_Script\r\n");
}
else{
printf("その他\r\n");
}
}
}
printf("-------------プログラム終了----------------");
Console::ReadLine();//入力待-ウインドウ維持
}
ラベル:
CLR,
Window Media SDK
システムプロファイルの言語を取得:IWMProfileManagerLanguage::GetUserLanguageID
To Load a System Profile
/*
空の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();//入力待-ウインドウ維持
}
ラベル:
CLR,
Window Media SDK
システムプロファイルの数を取得:IWMProfileManager::GetSystemProfileCount
/*
空の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();//入力待-ウインドウ維持
}
ラベル:
CLR,
Window Media SDK
登録:
コメント (Atom)



