在标准C ++中,我正在创建一个显示Window Toast消息的程序。通过修改XML本身很难显示Toast消息。
例如
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlDocument> pXmlDoc;
hr = RoActivateInstance(
HStringReference(RuntimeClass_Windows_Data_Xml_Dom_XmlDocument).Get(),
&pXmlDoc);
if (FAILED(hr))
{
return -1;
}
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlElement> pXmlElem;
hr = pXmlDoc->CreateElement(
HStringReference(_T("toaster")).Get(),
&pXmlElem);
if (FAILED(hr))
{
// Failed.
// Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
// This is usually a result of calling a function declared with one calling convention
// with a function pointer declared with a different calling convention.
return -1;
}
但是,当您使用ToastManagerStatics创建IXmlDocument而不直接创建它时,不会发生错误。
ComPtr<IToastNotificationManagerStatics> pToastManager;
hr = GetActivationFactory(
HStringReference(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(),
&pToastManager);
if (FAILED(hr))
{
return -1;
}
hr = pToastManager->GetTemplateContent(
mToastTemplate,
&pXmlDoc);
if (FAILED(hr))
{
return -1;
}
// return S_OK
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlElement> pXmlElem;
hr = pXmlDoc->CreateElement(
HStringReference(_T("toaster")).Get(),
&pXmlElem);
if (FAILED(hr))
{
return -1;
}
这两个程序代码都是在Win32控制台中编写的,并且没有对设置进行任何更改。
我想创建一个IXmlDocument,以便可以直接操纵该节点。有办法吗?