CD 또는 DVD에서 특성 값 읽기
[이 페이지와 연결된 기능인 Windows 미디어 플레이어 SDK는 레거시 기능입니다. MediaPlayer로 대체되었습니다. MediaPlayer는 Windows 10 및 Windows 11 최적화되었습니다. 가능한 경우 새 코드에서 Windows 미디어 플레이어 SDK 대신 MediaPlayer를 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
이 항목 전체에서 Player 개체는 다음과 같은 방식으로 정의되었습니다.
AxWMPLib.AxWindowsMediaPlayer Player;
using WMPLib;
다음 C# 예제 코드는 드라이브에 있는 현재 디스크에 있는 모든 특성의 값을 검색하여 파일에 씁니다.
private void logDiscAttributes()
{
int iCDCount = 0; // Count of CD and DVD drives
int iAttrCount = 0; // Attribute count.
int iPLCount = 0; // Playlist item count.
IWMPCdromCollection cdCollection;
IWMPPlaylist playlist;
IWMPMedia media;
string strAttribName = "";
string strAttribValue = "";
string strText = "";
// Create a StreamWriter object to write
// the output to a file.
StreamWriter sw = new StreamWriter(strOutFile, true);
cdCollection = Player.cdromCollection;
iCDCount = cdCollection.count;
// Loop through the CD and DVD drives.
for (int i = 0; i < iCDCount; i++)
{
playlist = cdCollection.Item(i).Playlist;
// Loop through the playlist attributes.
iAttrCount = playlist.attributeCount;
for (int j = 0; j < iAttrCount; j++)
{
strText += "Playlist Attribute: \t";
strAttribName = playlist.get_attributeName(j);
strText += "\t" + strAttribName + "\t";
strAttribValue = playlist.getItemInfo(strAttribName);
strText += strAttribValue + "\n";
}
// Loop through the playlist.
iPLCount = playlist.count;
for (int k = 0; k < iPLCount; k++)
{
media = playlist.get_Item(k);
// Loop through the media attributes.
iAttrCount = media.attributeCount;
for (int m = 0; m < iAttrCount; m++)
{
strText += "Track or Chapter [" + m.ToString() + "]";
strAttribName = media.getAttributeName(m);
strText += "\t" + strAttribName + "\t";
strText += "Read Only: " + media.isReadOnlyItem(strAttribName) + "\t";
strAttribValue = media.getItemInfo(strAttribName);
strText += strAttribValue + "\n";
}
}
}
sw.Write(strText);
sw.Close();
MessageBox.Show(strOutFile + " created");
}
관련 항목
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기