3

Suppose you have a .wma / .wmv file and you want to detect:

  1. is it DRM protected ?
  2. (then hopefully) details of the DRM protection (like when does the license expire etc.)?

Is there a C# / C++ api for it? It seems that Windows Media Player can do it - if you click properties on that file... but Explorer does not show this info.

Note: I do not belive this is a trivial question, I have tried taglib and searched the web for a solution for about 2 hours now.

Bogdan Gavril MSFT
  • 20,615
  • 10
  • 53
  • 74

2 Answers2

8

One method of detecting DRM files under a folder using Powershell is: -

$wmplayer = New-Object -ComObject "WMPlayer.OCX"
ls -recurse | ? { $_.Name -like "*.wma" -and [bool]::Parse($wmplayer.newMedia($_.FullName).getItemInfo("Is_Protected")) }
Blair Azzopardi
  • 502
  • 8
  • 17
  • This answer turned out to be just what I needed. I tested it a little to make sure it could be piped to `rm`, and then did that to remove all the DRM-cruft in my music folder: `ls -recurse | ? { $_.Name -like "*.wma" -and [bool]::Parse($wmplayer.newMedia($_.FullName).getItemInfo("Is_Protected")) } | rm` – sdesciencelover Dec 22 '13 at 02:28
  • Wow, this is an very useful response. It worked like a charm on all my wma files that still have DRM on them. – MKANET Apr 13 '14 at 02:41
3

From Here. More info on the Format SDK here

In c# using the Format SDK:

[DllImport("WMVCore.dll", CharSet=CharSet.Unicode)]

private static extern int WMIsContentProtected(string pwszFileName, out bool 
pfIsProtected);
keyboardP
  • 68,824
  • 13
  • 156
  • 205