|
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 < wAttribValueLen)
{
if ((0xFE == Convert.ToInt16(pbAttribValue[0])) &&
(0xFF == Convert.ToInt16(pbAttribValue[1])))
{
// UTF-16LE BOM+
if (4 <= wAttribValueLen)
{
for (int i = 0; i < pbAttribValue.Length - 2; i += 2)
{
strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
}
}
}
else if ((0xFF == Convert.ToInt16(pbAttribValue[0])) &&
(0xFE == Convert.ToInt16(pbAttribValue[1])))
{
// UTF-16BE BOM+
if (4 <= wAttribValueLen)
{
for (int i = 0; i < pbAttribValue.Length - 2; i += 2)
{
strDistributedBy += Convert.ToString(BitConverter.ToChar(pbAttribValue, i));
}
}
}
else
{
for (int i = 0; i < 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>
|
|
|
|
|
Hi,
I am trying to retrieve a shortcut's arguments but when I do so, I get some strange random/chinese symbols.
I've checked multiple times the code and I can't see any reason why this is happening.
I also use the IShellLinkW GetPath, but I have no problem with it.
here is the code I have :
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WIN32_FIND_DATAW
{
public int dwFileAttributes;
public FILETIME ftCreationTime;
public FILETIME ftLastAccessTime;
public FILETIME ftLastWriteTime;
public int nFileSizeHigh;
public int nFileSizeLow;
public int dwReserved0;
public int dwReserved1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string cFileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string cAlternateFileName;
}
[ComImportAttribute()]
[GuidAttribute("000214F9-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IShellLinkW
{
void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,
int cchMaxPath,
out WIN32_FIND_DATAW pfd,
uint fFlags);
void GetArguments([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs,
int cchMaxPath);
}
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("0000010B-0000-0000- C000-000000000046")]
public interface IPersistFile
{
[PreserveSig]
void IsDirty();
void GetClassID(out Guid pClassID);
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode);
}
[ComImport(), Guid("00021401-0000-0000-C000-000000000046")]
public class ShellLink
{
}
public class ShortcutTargetInfo
{
internal static string getArguments(string shortcutPath)
{
IShellLinkW linkW = (IShellLinkW)new ShellLink();
((IPersistFile)linkW).Load(shortcutPath, 0);
StringBuilder sb = new StringBuilder(260);
linkW.GetArguments(sb, sb.MaxCapacity);
Marshal.ReleaseComObject(linkW);
linkW = null;
return sb.ToString();
}
}
can anyone help me find the cause of this strange behavior.
|
|
|
|
|
I have an interface, I1 declared in library A, I use I1 in library B by writing code like
///////////////// begin /////////////////////
import "A.idl"
[
object,
uuid(...),
......
]
interface I2 : IDispatch{
[propget, id(1), helpstring("...")] HRESULT I1([out, retval] I1** prop);
};
///////////////// end ///////////////////
Both project A and project B built all right.
Now I import A.tlb and B.tlb in project C, and write following code
///////////////// begin /////////////////////
CComPtr < I1> spI1;
///////////////// end ///////////////////
compil failed with message error C2872 : "I1" : ambiguous symbol . While what I hope is only one I1, but now there are two.
How to resolve this problem?
|
|
|
|
|
Since you have import A.idl in B.idl, it would be enough to import only B.tlb.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Is there any other way to use I1 in B.idl except import?
What I really wonder is how to build a software structure like MS Office. In Office, the _CommandBars is in mso.dll, WinWord.Application is in WinWord.EXE, when I import MSWORD.OLB I can find there is code like "virtual HRESULT __stdcall get_CommandBars (
/*[out,retval]*/ struct Office::_CommandBars * * prop ) = 0;" in msword.tlh.
How it happens?!! In my projects, I import B.tlb, there is only "virtual HRESULT __stdcall get_I1 (
/*[out,retval]*/ struct I1 * * prop ) = 0;", while I am looking for "virtual HRESULT __stdcall get_I1 (
/*[out,retval]*/ struct A::I1 * * prop ) = 0;"
modified on Saturday, September 26, 2009 11:36 PM
|
|
|
|
|
You should use "importlib" in "library" section instead of "import" or in addition to "import".
With best wishes,
Vita
|
|
|
|
|
Make Extra Cash At Home Typing Ads for Companies. Work Part/Full-Time. Register Online Today! You are Paid per ad typed PLUS commissions. Sign up Today at http://www.clicknearn.net/3152-6.html
|
|
|
|
|
Don't post your spamming crap here, thank you very much!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I've been experimenting with this for weeks with no success. Basically, what I wanted to do is to use mshtml to render a html page in an ordinary window (form, or control), but I don't want to create a webbrowser object (from the shdocvw.dll or anywhere else)! MSHTML is claimed to be a html parser, renderer, and editor, I think it'd be neat and beautiful to just use it to render a html page in any winodw without the extras from a webbrowser object. I've tried over ten example projects from this website and they all need to create a webbrowser object one way or another, which seems redundent or which is a necessary step? Any ideas from you all?
|
|
|
|
|
I'm pretty sure you would need a control which is capable of rendering HTML like the web browser control or a word document object.
I believe MSHTML is a parser of HTML and not a renderer.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I am not sure about what you believed since according tp msdn:
"Mshtml.dll is at the heart of Internet Explorer and takes care of its HTML and Cascading Style Sheets (CSS) parsing and rendering functionality. "
|
|
|
|
|
Rendering is always done by a control. Examples.... web browser control, media player control, a view, edit box.... Something that is visible.
Does MDHTML have any such visible views?
You certainly will not able to render HTML in an edit box.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hello everyone,
I am creating the ATL COM project using VC++ in VS2008.
My project need to access the database from the mysql.
I have installed the mysql ODBC connector.
Please tell me how to connect to mysql through
my ATL COM project and how to insert , delete data from the tables present in my database.
|
|
|
|
|
Now i am able to do that.
i can connect to mysql,edit,delete and insert a
new record in the database.
|
|
|
|
|
how to write corba application from java to java????????
|
|
|
|
|
This looks like a java question; I would suggest you post it to the Java forum.
|
|
|
|
|
Hi,
Again I am here with new one.
Following is the code , I am attaching the instance of excel to active excel.
Excel::_ApplicationPtr XL;
Excel::_WorkbookPtr book;
string XLWBName;
try
{
CoInitialize(NULL);
HRESULT hr = XL.GetActiveObject(_T("Excel.Application"));
book = XL->;Workbooks->;Item[1];
XLWBName = book->Name;
return true;
}
catch(_com_error &error)
{
cout << "COM error"<< endl;
return false;
}
I implemented this in two applications:
In 1st application it is working perfectly , after coinitialize i kept the breakpoint then it is called 2 methods from comip.h
1st is:HRESULT GetActiveObject(const CLSID& rclsid) throw()
2nd is: HRESULT GetActiveObject(LPCWSTR clsidString) throw()
In 2nd application it is not working and checked the sequence of methods calling from comip.h, its calling only one method that is :
HRESULT GetActiveObject(LPCWSTR clsidString) throw()
Checked the value of book and other instances:
((*(IUnknown*)(&(*(IDispatch*)(&*((book).m_pInterface)))))).__vfptr
__vfptr = CXX0030: Error: expression cannot be evaluated
[0] = 0x0046d5b0 _com_error::`scalar deleting destructor'(unsigned int)
__vfptr = 0x004f5af4 const _com_error::`vftable'
please give me clue where I am doing wrong or something need to be added?
Regards,
Gtag
|
|
|
|
|
Is the second application compiled with Unicode turned on? Because your passing an LPCTSTR (which can be ASCII or Unicode, depending on pre-processor macro settings) to GetActiveObject, where you are meant to pass an LPCWSTR
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Sorry I am new to this, I searched for this option, i didn't find it?
Please tell me where I can find this option in Microsoft visual studio 2008(Professional edition).
Regards,
gtag
|
|
|
|
|
Don't worry too much about that - just make sure you use
L"Excel.Application"
instead of
_T("Excel.Application")
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I changed it , but same issue.
Is there any other way?
Regards,
Gtag
|
|
|
|
|
What HRESULT was returned from GetActiveObject?
Was Excel running when you did the GetActiveObject call?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hr = 0x800401e3 Operation unavailable
Excel was running.
With other application I can attach with both option s _T or L.
Even can read xlworksheet names and all.
Regards,
Gtag
|
|
|
|
|
gtag wrote: hr = 0x800401e3 Operation unavailable
Right - well that explains why you weren't getting a pointer to the Excel application. Doing a quick Google (you know, like you could have done) brings up this MS support page[^] which deals with your scenario.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|