|
Heres the code
String strPathName;
strPathName = "C:\\My Documents\\C_Projects\\XML\\books.xml";
CString csString;
HRESULT hr;
hr = CoInitialize(NULL);
if (FAILED(hr)) {
return;
}
hr = CoCreateInstance(MSXML::CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
MSXML::IID_IXMLDOMDocument, (LPVOID*)&document);
if (!document)
{
return;
}
BSTR bstr = NULL;
document->put_async(VARIANT_FALSE);
bstr = strPathName.AllocSysString();
VARIANT_BOOL varOkay = document->load(bstr);
SysFreeString(bstr);
BSTR nodeName;
if (varOkay)
{
hr = document->get_documentElement(&element);
if (FAILED(hr) || element == NULL)
{
MessageBox(_T("Empty document!"), _T("Error Loading XML"), MB_ICONWARNING);
return ;
}
element->get_nodeName(&nodeName);
m_List.AddString(CString(nodeName));
if(element->hasChildNodes())
{
MSXML::IXMLDOMNode* firstChild = NULL;
HRESULT hr;
hr = element->get_firstChild(&firstChild);
if (SUCCEEDED(hr) && firstChild != NULL)
{
((MSXML::IXMLDOMElement*)firstChild)->get_nodeName(&nodeName);
m_List.AddString(CString(nodeName));
}
}
MSXML::IXMLDOMElementPtr node;
node = document->createElement("Test");
document->appendChild(node);
}
else
{
long line, linePos;
BSTR reason = NULL;
document->get_parseError(&parseError);
parseError->get_errorCode(&hr);
parseError->get_line(&line);
parseError->get_linepos(&linePos);
parseError->get_reason(&reason);
CString strMsg;
strMsg.Format(_T("Error 0x%.8X on line %d, position %d\r\nReason: %s"),
hr, line, linePos, CString(reason));
MessageBox(strMsg, _T("Error Loading XML"), MB_ICONWARNING);
SysFreeString(reason);
return;
}
on the line -- document->appendChild(node);
is gives the error
Unhandled exception in XML.exe(kernal32.dll); 0xEO6D7363; Microsoft C++ Exception
Scott
|
|
|
|
|
Try appending your newly created node to the "element" or root nod eof your document rather than your document. I beleive your problem is that there is already a root element in the document and that is why there is a problem. However appending your new node ot the root element of the document seems to work fine.
If you have any other questions feel free to ask.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Might not solve the issue, but the API says the child must be a IXMLDOMNode* , not a IXMLDOMElement* .
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I have class derivative from CView and I want to put it in
CPropertyPage class.
How can I do it?
Is any example program in the Internet?
Mithrandir
|
|
|
|
|
look at http://www.codeproject.com/docview/dfv.asp here at CodeProject. it helped me to place my doc/view architecture in dialog.
maybe it will help you too.
Dmitry Timin
|
|
|
|
|
I am trying to overload the stream insertion operator, I have defined my class like this:
#ifndef Time_h
#define Time_h
class Time
{
protected:
int hour;
int minute;
bool night;
public:
Time()
{
hour = 12;
minute = 0;
night = false;
}
Time(int H, int M, bool N)
{
hour = H;
minute = M;
night = N;
}
void Set(int, int, bool);
int GetHour();
int GetMin();
bool GetNight();
void Increment();
<font color="red">friend ostream &operator<<(ostream &, Time &);</font>
};
#endif
However I get a slew of errors, but the first one points to the line I highlighted in red saying:
<br />
c:\documents and settings\user\desktop\hw3\time.h(36) : error C2143: syntax error : missing ';' before '&'<br />
Does something look wrong with this declaration? Thanks in advance.
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
My first guess is you didn't #include <iostream> since the error occurs right after the "ostream" token.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
My first guess is you didn't #include <iostream> since the error occurs right after the "ostream" token.
Thanks, that was it , I think I need to step away from the computer again.
I hate missing those little things.
Nick Parker
So like children pointers should be left to grown ups. - Norm Alomond
|
|
|
|
|
if i want to get HWND the currently active window (on which user is working).how to get it ?
if i want to get active window (on which user is working)
component say Button HWND.how to get it?
may i know process id from a HWND?
may i know who many window AND sub window HWND'S are open by a process?if yes how?
r00d0034@yahoo.com
|
|
|
|
|
GetForegroundWindow will return the handle to the window that the user is working in.
If you want to get the handle to a particular button, it would be helpful to have the parent HWND and you can enumerate through the child windows of the parent window. Or you can use Find window and search for your button.
As far as getting the process of an HWND I think that you will first have to get teh thread ID that owns the window, then determine the process from that method.
As far as getting the number of windows for a particular process I cannot think of anyway except for enumerating all of the windows in the system, determining the process that it belongs to, and keep a running count. However there may be a simpler way with an API that I am not aware of.
Good LUck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Q.
how to get process id from hwnd?
Ans.
As far as getting the process of an HWND I think that you will first have to get teh thread ID that owns the window, then determine the process from that method.
can u explain it more briefly?plz give an code example?
r00d0034@yahoo.com
|
|
|
|
|
may i transfer an object from one computer to another on the network ?
if yes how?
r00d0034@yahoo.com
|
|
|
|
|
By object, you mean an instance of a C++ class? Yes, it is possible, by some mean of serialization. It can be an implementation of yours, or you could use some already available mechanism.
You need to be more specific.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
let say i want to transfer an object of CFile
how to transfer an object of it?
there is one way i know and that is tranfer the file bit by bit or using string transfer the file and again construct it on remote location.
BUT i want to tranfer the file object if it is possible writ the syntex of it ?plz?
r00d0034@yahoo.com
|
|
|
|
|
Yes,
if you simply have the code to handle the object on both machines, you can copy the data from the object to a flat stream of memory, then send that memory to the other machine and reconsitute the object.
If you do not have the code to run the object on the other machine, it is still possible to run the object on the other machine, but it is a lot of work, and opens up security holes.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
is it possible when my application is running no other application could recive any type of keboard message and mouse messages.
while my running application recive it ?
r00d0034@yahoo.com
|
|
|
|
|
yes, try message hooks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
is it possible to log off any system programatically?
if yes how in vc++ and how in csharp?
r00d0034@yahoo.com
|
|
|
|
|
BOOL bStatus = ::ExitWindowsEx (EWX_LOGOFF, 0);
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
please read that code and solve my problem.
Given after that code.
///////////////////////////////////////////////////////////
>>><<<
public class Win32Hook
{
[DllImport("kernel32")]
public static extern int GetCurrentThreadId();
[DllImport( "user32", CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern int SetWindowsHookEx( HookType idHook,
HOOKPROC lpfn,
int hmod,
int dwThreadId
);
public enum HookType
{
WH_KEYBOARD = 2
}
public delegate int HOOKPROC(int nCode, int wParam, int lParam);
private HOOKPROC hookProc;
public void SetHook()
{
hookProc = new HOOKPROC(this.MyKeyboardProc);
SetWindowsHookEx(HookType.WH_KEYBOARD, hookProc, 0,
GetCurrentThreadId());
}
public int MyKeyboardProc(int nCode, int wParam, int lParam)
{
return 0;
}
}
To install the hook procedure
Win32Hook hook = new Win32Hook();
hook.SetHook();
///////////////////////////////////////////////////////////
Above code is 100% correct but my problem here is that I want to execute it for each thread for that purpose I modify a line of code and that is
SetWindowsHookEx (HookType.WH_KEYBOARD, hookProc, IntPtr.Zero,0 );
But after changing that line of code it does not solve my problem because MyKeyboardProc function does not execute its code.
I don’t know why? Can any body give its solution?
r00d0034@yahoo.com
|
|
|
|
|
Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock
|
|
|
|
|
Check out SetTimer() and WM_TIMER
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Basically, use liek this, with ON_WM_TIMER()
SetTimer(1, 3600 000, NULL);
3600 000 here indicates an hour... it's in msec.
so the code would look like.....
int iTimer = 0; //global variable to count time
//this will get invoked every hour
YourClass::OnTimer(UINT nIDEvent)
{
iTimer=iTimer+1;
if(iTimer == 12){
//do your processing....
}
if (iTimer == 24){
iTimer = 0;
}
}//end of fn
hope this helps dude.
jey
|
|
|
|
|
Thanks very much for the direction.
I don't suppose you have some small source files you could send me. I'm new to programming and I have a hard time putting the code in the right place. usually when I see the source files I can just duplicate what was done before and make it work.
Thank again. Mavrock
my email is stonematthies@hotmail.com
|
|
|
|
|
For this waitable timers are best, because (as opposite to WM_TIMER) they do not work only with relative time, but also with absolute time and therefore fire at the right moment even if the machine was down in the mean time, the clock was adjusted or something else.
Check out CreateWaitableTimer() for more info about waitable timers.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|