[
Lists Home |
Date Index |
Thread Index
]
- From: Sung_Nguyen@datacard.com (Sung Nguyen)
- To: Tyler Baker <tyler@infinet.com>, Fernando Cabral <fernando@pix.com.br>
- Date: Fri, 6 Nov 1998 20:09:51 -0600
Hi all:
I have trouble with linking the following example (downloaded from
MicroSoft site)
This is the link error I got:
"G:\mssdk\lib\ole32.lib : fatal error LNK1106: invalid file or disk
full: cannot seek to 0x35cb1cf1"
The two files: "mshtml.h" msxml.h" I got from Internet SDK with IE4.0
I don't know if they are still compatible with IE5.0 and where I can
get new "mshtml.h" msxml.h" for IE5.0.
Please point me the direction,
Thanks a lot,
SeanN
--------------------------------------
//////////////////////////////////////////////////////////////////////
//////
// Sample1.cxx: XML Object Model Sample 1
//--------------------------------------------------------------------
------
// Copyright (c) 1998 Microsoft Corporation. All Rights Reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//--------------------------------------------------------------------
------
//////////////////////////////////////////////////////////////////////
//////
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <hlink.h>
#include <dispex.h>
#include "mshtml.h"
#include "msxml.h"
#include <winnls.h>
#define CHECKHR(x) hr = x; if (FAILED(hr)) goto Cleanup;
#define SAFERELEASE(p) if (p) {(p)->Release(); p = NULL;} else ;
//////////////////////////////////////////////////////////////////////
//////
// Synopsis: Create an IXMLElement of type t
//////////////////////////////////////////////////////////////////////
//////
IXMLElement* CreateXMLElement(IXMLDocument* pDoc, XMLELEM_TYPE t)
{
IXMLElement* e;
VARIANT type;
type.vt = VT_I4;
V_I4(&type) = t;
VARIANT name;
name.vt = VT_BSTR;
V_BSTR(&name) = ::SysAllocString(L"ElementNode");
HRESULT hr = pDoc->createElement(type, name, &e);
::SysFreeString(V_BSTR(&name));
return e;
}
//////////////////////////////////////////////////////////////////////
//////
// Synopsis: Create an XML Document from Scratch in memory
//////////////////////////////////////////////////////////////////////
//////
HRESULT MemDocument()
{
IXMLDocument *pDoc = NULL;
IStream *pStm = NULL;
IPersistStreamInit *pPSI = NULL;
IXMLElement *enode = NULL, *el = NULL;
IXMLElement *root = NULL;
LARGE_INTEGER li = {0, 0};
HRESULT hr = S_OK;
int i, j;
// Create an empty XML document
CHECKHR(CoCreateInstance(CLSID_XMLDocument, NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDocument, (void**)&pDoc));
// Query the IPersistStreamInit interface
CHECKHR(pDoc->QueryInterface(IID_IPersistStreamInit, (void
**)&pPSI));
// Create an IStream
CHECKHR(CreateStreamOnHGlobal(NULL, TRUE, &pStm));
pStm->AddRef();
//
// Create an xml document with a root element
//
ULONG ulWritten;
CHECKHR(pStm->Write("<root/>", strlen("<root/>"), &ulWritten));
// load the xml document
CHECKHR(pStm->Seek(li, STREAM_SEEK_SET, NULL));
CHECKHR(pPSI->Load(pStm));
// get root element
CHECKHR(pDoc->get_root(&root));
//
// Create an xml document in memory
//
for (i = 10; i > 0; i--)
{
enode = CreateXMLElement(pDoc, XMLELEMTYPE_ELEMENT);
CHECKHR(root->addChild(enode, -1, -1));
for (j = 10; j > 0; j--)
{
el = CreateXMLElement(pDoc, XMLELEMTYPE_ELEMENT);
CHECKHR(enode->addChild(el, -1, -1));
SAFERELEASE(el);
}
SAFERELEASE(enode);
}
CHECKHR(pStm->Seek(li, STREAM_SEEK_SET, NULL));
CHECKHR(pPSI->Save(pStm, TRUE));
//
// Load the document from the in-memory stream
//
CHECKHR(pStm->Seek(li, STREAM_SEEK_SET, NULL));
CHECKHR(pPSI->Load(pStm));
Cleanup:
SAFERELEASE(root);
SAFERELEASE(el);
SAFERELEASE(enode);
SAFERELEASE(pPSI);
SAFERELEASE(pStm);
SAFERELEASE(pDoc);
return hr;
}
int _cdecl
main(int argc, char *argv[])
{
HRESULT hr = S_OK;
CoInitialize(NULL);
hr = MemDocument();
CoUninitialize();
return hr == 0 ? 0 : 1;
}
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)
|