search: VARIANT, XML, C++, IXMLDOMDocument, etc.

Started by
4 comments, last by TheHermit 21 years, 5 months ago
Yeah, ok, the forum search engine still doesn''t work (no pressure, btw) so these are the terms I am needing some clarification on...
  
IXMLDOMDocument * pDoc;

//Init COM...



VARIANT filename;
filename.vt = VT_BSTR;
filename.bstrVal = CComBSTR("text.xml");
VARIANT_BOOL * result = false;

HRESULT loadResult = pDoc->load(filename, result);

  
I am really struggling to find wtf is going wrong here.., As load returns E_INVALID_ARG to my efforts. Have also attempted to use CComVariants for filename, but to no success. Currently googling for answers, as MSDN just does not make it clear to me what is wrong with this code, but if anyone has suggestions, please do... Thanks...
Advertisement
Maybe this line:

  VARIANT_BOOL * result = false;  

You set result (which is pointer) to false (=NULL).
I think you mean here this:

  bool b = false;VARIANT_BOOL * result = &b  
You want this:

VARIANT_BOOL result;
HRESULT loadResult = pDoc->load( filename, &result );


BTW, is there any reason why you''re not using ATL (to it''s fullest, you''ve got a CComBSTR in there)? It really makes your life easier when you''re dealing with COM, i.e. you could actually do something like this:

CComPtr pDoc( "The.ProgID" );
try
{
BOOL bResult = pDoc->load( _T("text.xml") );
}
catch( _com_error err )
{
DisplayError( err.Description() );
}


And so on...

If I had my way, I''d have all of you shot!

codeka.com - Just click it.
Thanks, will try later today...
First off, thanks above - got rid of the E_INVALIDARG (My problem answered in docs below - which i had read, but didn''t absorb)

But...

OK. MSDN''s kinda ambiguous docs state that:


  C/C++ Return ValuesS_OK -Value returned if successful. S_FALSE -Value returned if the load fails. E_INVALIDARG -Value returned if isSuccessful is Null.   


Unfortunately, S_FALSE is the answer I am receiving to my request and it doesn''t give any hints to why the failure. I am getting this in the debug window:


  First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.  


But am unsure of the problem... The paramaters (appear) correct in the debug, the file is there (have checked current dir at runtime) - and valid (will post if disbelief occurs, but pretty sure).

Any help appreciated.., thanks
If you use ATL the way I described, the _com_error object will have extra error info you can look at (for example by using the Description() method).

If I had my way, I''d have all of you shot!

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement