Click here to Skip to main content
15,890,512 members
Home / Discussions / COM
   

COM

 
GeneralRe: Getting Excel sheet names Pin
Stuart Dootson3-Oct-09 0:11
professionalStuart Dootson3-Oct-09 0:11 
GeneralRe: Getting Excel sheet names Pin
Richard MacCutchan3-Oct-09 0:39
mveRichard MacCutchan3-Oct-09 0:39 
GeneralRe: Getting Excel sheet names Pin
gtag3-Oct-09 0:43
gtag3-Oct-09 0:43 
GeneralRe: Getting Excel sheet names Pin
gtag12-Nov-09 18:31
gtag12-Nov-09 18:31 
QuestionCall an COM Server dispinterface C++ Pin
Juergen_8030-Sep-09 4:58
Juergen_8030-Sep-09 4:58 
AnswerRe: Call an COM Server dispinterface C++ Pin
Juergen_801-Oct-09 21:14
Juergen_801-Oct-09 21:14 
AnswerRe: Call an COM Server dispinterface C++ Pin
Stuart Dootson1-Oct-09 22:03
professionalStuart Dootson1-Oct-09 22:03 
QuestionWMP SDK 11 audio and video file DRM and attribute querying Pin
Barney Wray29-Sep-09 5:17
Barney Wray29-Sep-09 5:17 
Hi - thanks in advance for any enlightenment you can provide!!

I have a basic C# app running on XP SP2, using the Media Player 11 SDK download.   Code looks like the following...

- The PROBLEM is that this runs OK for a WMA audio file, but throws for a WMV file on the line
drm.GetDRMProperty( strWMDRM_ActionAllowed_Playback,...   with HRESULT 0xC00D002B, which is NS_E_INVALID_REQUEST

- so the QUESTIONs:
1) The IsDRM attribute that I can query on the WMA, which I found in the SDK drmexternals.h, Why is this not anywhere
in the SDK sample code, or elsewhere in the SDK includes?   It is not documented in Microsoft's media attributes lists either.

2) Where can I get better info regarding audio vs video file attribute and DRM querying in C++ or C#?

3) How can I query WMV for playability and protection, as I have working for WMA?

code....

<pre>
// File attributes to be queried
public string strATTR_IsProtected = "Is_Protected";

// DRM properties to be queried
// This works for wma, but not wmv??   Do not see this in the DRM attribute list in Help.
public string strWMDRM_IsDRM     = "IsDRM";

public string strWMDRM_ActionAllowed_Playback = "ActionAllowed.Play";
public string strWMDRM_DRMHeader_LicenseAcqURL = "DRMHeader.LAINFO";


private void OnPickAudioFileToPlay(object sender, EventArgs e)
{
     OpenFileDialog openFileDlg = new OpenFileDialog();

     openFileDlg.InitialDirectory = "c:\\";
     openFileDlg.Filter = "WMA files (*.wma)|*.wma|MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*";
     openFileDlg.FilterIndex = 0;
     openFileDlg.RestoreDirectory = true;

     checkBoxFileProtected.Checked = false;

     DialogResult dr = openFileDlg.ShowDialog();
     if (DialogResult.OK == dr)
     {
          string file = openFileDlg.FileName;

          // Get properties
          // from wmsdkidl.h
          // static const WCHAR g_wszWMProtected[] =L"Is_Protected";

          IWMMetadataEditor editor;
          IWMHeaderInfo3 hi3;
          IWMDRMEditor drm;

          bool bLocked = false;
          uint iRes;

          try
          {
               iRes = WMFSDKFunctions.WMCreateEditor(out editor);
               bool bProtected = false;
               string strDistributedBy = null;

               editor.Open(file);
               hi3 = (IWMHeaderInfo3)editor;

               ushort wAttribValueLen = 4;
               byte[] pbAttribValue = new Byte[wAttribValueLen];

               WMT_ATTR_DATATYPE wAttribType;
               ushort pwStreamNum = 0;

               iRes = hi3.GetAttributeByName(
                    ref pwStreamNum,
                    strATTR_IsProtected,
                    out wAttribType,
                    pbAttribValue,
                    ref wAttribValueLen);

               bProtected = BitConverter.ToBoolean(pbAttribValue, 0);

               drm = (IWMDRMEditor)editor;

               iRes = drm.GetDRMProperty(
                    strWMDRM_ActionAllowed_Playback,
                    out wAttribType,
                    pbAttribValue,
                    ref wAttribValueLen);

               bLocked = (!BitConverter.ToBoolean(pbAttribValue, 0));

               checkBoxFileProtected.Checked = bProtected;
               checkBoxFileLocked.Checked = bLocked;

               if (bLocked)
               {
                    pbAttribValue = null;

                    iRes = drm.GetDRMProperty(
                         strWMDRM_DRMHeader_LicenseAcqURL,
                         out wAttribType,
                         pbAttribValue,
                         ref wAttribValueLen);

                    pbAttribValue = new byte[wAttribValueLen];

                    iRes = drm.GetDRMProperty(
                         strWMDRM_DRMHeader_LicenseAcqURL,
                         out wAttribType,
                         pbAttribValue,
                         ref wAttribValueLen);

                    if (2 &lt; wAttribValueLen)
                    {
                         if ((0xFE == Convert.ToInt16(pbAttribValue[0])) &amp;&amp;
                              (0xFF == Convert.ToInt16(pbAttribValue[1])))
                         {
                              // UTF-16LE BOM+
                              if (4 &lt;= wAttribValueLen)
                              {
                                   for (int i = 0; i &lt; pbAttribValue.Length - 2; i += 2)
                                   {
                                        strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
                                   }
                              }
                         }
                         else if ((0xFF == Convert.ToInt16(pbAttribValue[0])) &amp;&amp;
                                      (0xFE == Convert.ToInt16(pbAttribValue[1])))
                         {
                              // UTF-16BE BOM+
                              if (4 &lt;= wAttribValueLen)
                              {
                                   for (int i = 0; i &lt; pbAttribValue.Length - 2; i += 2)
                                   {
                                        strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
                                   }
                              }
                         }
                         else
                         {
                              for (int i = 0; i &lt; pbAttribValue.Length - 2; i += 2)
                              {
                                   strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
                              }
                         }
                    }
               }

               textBoxDistributedBy.Text = strDistributedBy;

          }
          catch( System.Runtime.InteropServices.COMException ex)
          {
               Console.WriteLine( ex.Message );
               return;
          }

          // Play file...
          if (! bLocked)
          {
               textPlayAudioFile.Text = file;
               axWindowsMediaPlayer1.URL = file;
          }

     }

}     // END pick file to play

<\pre>
QuestionIShellLinkW getArguments gives some strange symbols instead of the shortcuts' arguments Pin
coderomega26-Sep-09 11:26
coderomega26-Sep-09 11:26 
Questionhow to use an interface belong to another library in idl file Pin
samfromcn26-Sep-09 1:26
samfromcn26-Sep-09 1:26 
AnswerRe: how to use an interface belong to another library in idl file Pin
«_Superman_»26-Sep-09 6:49
professional«_Superman_»26-Sep-09 6:49 
GeneralRe: how to use an interface belong to another library in idl file [modified] Pin
samfromcn26-Sep-09 15:50
samfromcn26-Sep-09 15:50 
AnswerRe: how to use an interface belong to another library in idl file Pin
Vi228-Sep-09 20:14
Vi228-Sep-09 20:14 
QuestionMake Extra Cash At Home Pin
aqasim25-Sep-09 1:21
aqasim25-Sep-09 1:21 
AnswerRe: Make Extra Cash At Home Pin
Stuart Dootson25-Sep-09 2:38
professionalStuart Dootson25-Sep-09 2:38 
AnswerRe: Make Extra Cash At Home Pin
Richard MacCutchan25-Sep-09 5:56
mveRichard MacCutchan25-Sep-09 5:56 
QuestionRendering html pages wth mshtml alone (no webbrowser object or shdocvw!) Pin
gxie23-Sep-09 16:46
gxie23-Sep-09 16:46 
AnswerRe: Rendering html pages wth mshtml alone (no webbrowser object or shdocvw!) Pin
«_Superman_»23-Sep-09 20:38
professional«_Superman_»23-Sep-09 20:38 
GeneralRe: Rendering html pages wth mshtml alone (no webbrowser object or shdocvw!) Pin
gxie24-Sep-09 3:03
gxie24-Sep-09 3:03 
GeneralRe: Rendering html pages wth mshtml alone (no webbrowser object or shdocvw!) Pin
«_Superman_»24-Sep-09 21:25
professional«_Superman_»24-Sep-09 21:25 
QuestionHow to use Mysql Database in ATLCOM project. Pin
Rits11038923-Sep-09 1:22
Rits11038923-Sep-09 1:22 
AnswerRe: How to use Mysql Database in ATLCOM project. Pin
Rits11038915-Oct-09 20:54
Rits11038915-Oct-09 20:54 
Questioncorba application from java to java Pin
jayshree1822-Sep-09 2:50
jayshree1822-Sep-09 2:50 
AnswerRe: corba application from java to java Pin
Richard MacCutchan22-Sep-09 4:45
mveRichard MacCutchan22-Sep-09 4:45 
Questionexpression cannot be evaluated:0x0046d5b0 _com_error Pin
gtag17-Sep-09 21:06
gtag17-Sep-09 21:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.