Click here to Skip to main content
15,920,513 members
Home / Discussions / COM
   

COM

 
QuestionIDispatch and bookmarks in word Pin
lparsonson21-Feb-06 4:37
lparsonson21-Feb-06 4:37 
QuestionConnecting to a running IE COM instances. Pin
TClarke21-Feb-06 3:42
TClarke21-Feb-06 3:42 
QuestionAccess violation in ADODB::Connection Pin
Dyrl20-Feb-06 7:13
Dyrl20-Feb-06 7:13 
AnswerRe: Access violation in ADODB::Connection Pin
lparsonson21-Feb-06 4:35
lparsonson21-Feb-06 4:35 
GeneralRe: Access violation in ADODB::Connection Pin
Dyrl21-Feb-06 8:48
Dyrl21-Feb-06 8:48 
GeneralRe: Access violation in ADODB::Connection Pin
lparsonson21-Feb-06 22:39
lparsonson21-Feb-06 22:39 
QuestionAcitveX component, "off form", like the timer Pin
david_reynolds19-Feb-06 14:37
david_reynolds19-Feb-06 14:37 
Questionhow to load xml schema from resource? Pin
dolph_loe19-Feb-06 10:32
dolph_loe19-Feb-06 10:32 
Hi I want to include an xml validation schema as a part of an executable. My problem is how to add the schema to the MSXML2::XMLSchemaCache40. I have a schema called 'setup.xsd', and m_schemaCache is a MSXML2::IXMLDOMSchemaCollection2 interface to XMLSchemaCache40.

The following code works ('setup' is the namespace for the schema).

<br />
hr = m_schemaCache->add(L"setup", L"Setup.xsd");<br />



Now I want to load the schema from a resource. Since IXMLDOMSchemaCollection2::add only accepts url's or MSXML2::DOMDocument's, I decided to parse the xml data using DOMDocument, and then pass the DOMDocument over to the XMLSchemaCache40.

In the following code, everything seems to be ok until I try to add the DOMDocument to the XMLSchemaCache40. The resource is loaded, The DOMDocument parses it, and no errors are found. The readyState of the DOMDocument is 4.

<br />
//Create resource name from resource id<br />
wchar_t  sResName[10];<br />
swprintf_s(sResName, 10, L"#%d", resourceId);<br />
<br />
//Locate the resource<br />
TCHAR sRestype[13] = _T("SCHEMA");<br />
HRSRC hres = FindResource(NULL, sResName, sRestype);<br />
if (hres == 0) { <br />
	return false;<br />
}<br />
<br />
//If resource is found a handle to the resource is returned<br />
//now just load the resource<br />
HGLOBAL    hbytes = LoadResource(NULL, hres);<br />
<br />
// Lock the resource<br />
LPVOID pdata = LockResource(hbytes);<br />
<br />
//Convert the resource text file to data we can use<br />
LPBYTE sData = (LPBYTE)pdata;<br />
BSTR sXml = _bstr_t((char*) sData);	<br />
<br />
//Crate instance of DOM parser<br />
MSXML2::IXMLDOMDocument* doc;<br />
hr = CoCreateInstance(__uuidof(MSXML2::DOMDocument), NULL, CLSCTX_ALL,<br />
		__uuidof(MSXML2::IXMLDOMDocument), (void**) &doc);<br />
if (FAILED(hr))<br />
	return false;<br />
<br />
//We don't want async read<br />
doc->put_async(VARIANT_FALSE);<br />
doc->put_validateOnParse(VARIANT_TRUE);<br />
<br />
//Parse the xml schema we just loaded from our resources<br />
VARIANT_BOOL succeeded;<br />
hr = doc->loadXML(sXml, &succeeded);<br />
if (succeeded != VARIANT_TRUE) {<br />
	//Load failed<br />
	return false;<br />
}	<br />
<br />
//HERE IT FAILS!!!!!!<br />
//Add the loaded schema to the schema collection<br />
hr = m_schemaCache->add(bstrNamespace, _variant_t(doc));<br />
if ( FAILED(hr) )<br />
	return false;<br />
<br />
return true;<br />


What am I doing wrong? Thanks in advance for any answers Smile | :)

øivind
Questionocx replace Pin
mahmoodi18-Feb-06 20:29
mahmoodi18-Feb-06 20:29 
QuestionBindToStorage HRESULT fails while using IPropertyBag2 Pin
nripun18-Feb-06 3:48
nripun18-Feb-06 3:48 
AnswerRe: BindToStorage HRESULT fails while using IPropertyBag2 Pin
mbue18-Feb-06 21:18
mbue18-Feb-06 21:18 
QuestionEvent Notification using Windows MAnagement Instrumentation Pin
abhiramsss17-Feb-06 1:14
abhiramsss17-Feb-06 1:14 
AnswerRe: Event Notification using Windows MAnagement Instrumentation Pin
oshah20-Feb-06 3:11
oshah20-Feb-06 3:11 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss21-Mar-06 21:18
abhiramsss21-Mar-06 21:18 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
oshah22-Mar-06 1:03
oshah22-Mar-06 1:03 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss2-Apr-06 23:37
abhiramsss2-Apr-06 23:37 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss5-Apr-06 19:21
abhiramsss5-Apr-06 19:21 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss22-May-06 19:17
abhiramsss22-May-06 19:17 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
oshah23-May-06 6:42
oshah23-May-06 6:42 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss28-May-06 23:36
abhiramsss28-May-06 23:36 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
oshah29-May-06 6:54
oshah29-May-06 6:54 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss30-May-06 20:48
abhiramsss30-May-06 20:48 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss12-Jun-06 21:03
abhiramsss12-Jun-06 21:03 
GeneralRe: Event Notification using Windows MAnagement Instrumentation Pin
abhiramsss26-Jun-06 18:18
abhiramsss26-Jun-06 18:18 
GeneralWindows MAnagement Instrumentation Pin
abhiramsss7-Nov-06 14:32
abhiramsss7-Nov-06 14:32 

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.