|
|
These are COM methods they return HRESULTs not interface pointers.
getNamedItem method takes two parameters.
From MSXML 4.0 documentation
C/C++ Syntax
HRESULT getNamedItem(
BSTR name,
IXMLDOMNode **namedItem);
Parameters
name [in]
The name of the attribute.
namedItem [out, retval]
An IXMLDOMNode object for the specified attribute. Returns Null
if the attribute node is not in this collection.
|
|
|
|
|
Hi! I am working on an application that requires the display of data graphically - ideally the same as in the AXE hex editor where one colour block represents one byte and a file can be shown as a panel. As a newbie, trying to navigate through the MFC documentation is a nightmare. Anyone able to assist please? If you're anywhere near Ireland, a solution is worth a number of pints of the black stuff!!
Brian Scott
|
|
|
|
|
Brian,
This should fit the bill nicely: http://codeproject.com/tips/frhed.asp.
PS: You can email me the brew.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
I have a COM server (A.exe) it supports two interfaces I1 and I2. I also have two services S1.exe and S2.exe. S1 creates and instance of I1 and S2 creates an instance of I2.
I expected to find only one A.exe running. Instead I find two. This is a problem for two reasons. S2 must release and recreate the interface regularly, causing the initialization of A.exe to happen way too often. The other issue is that I2 and I1 share a global array (protected by a MUTEX). This sharing clearly won't work if there are two separate eA.exes.
Is it possible to do this so only one A.exe is launched? If so, how?
We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today.
Thanks for the help,
Bill
|
|
|
|
|
Try this, it MAY solve your problem
Add this BEFORE the COM_MAP of your Interface
DECLARE_CLASSFACTORY_SINGLETON(CYourI1InterfaceClass)
- Greatest invention : "The Microchip!"
|
|
|
|
|
I tried it, but it didn't help. I think its because there are two apps accessing two different interfaces, rather than two apps accessing the same interface.
Next attempt is to use CoGetClassObject. MSDN says:
"Provides a pointer to an interface on a class object associated with a specified CLSID. CoGetClassObject locates, and if necessary, dynamically loads the executable code required to do this."
Sounds like it won't load the EXE if it's already there. This coincides with VB and GetObject versus CreateObject.
Unfortunately I get an error AND the wrong effect:
hr = CoGetClassObject(ID, CLSCTX_LOCAL_SERVER, NULL,
IID_IDispatch, (void **)&(m_pBroker));
if(hr = S_OK)
{
g_pErrorLog->LogError(4,"Get Class succeeded " + strObjName,_strModule);
} else {
hr = CoCreateInstance(ID, NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch, (void **)&(m_pBroker));
g_pErrorLog->LogError(4,"Try to CoCreate",_strModule);
}
When it executes the CoGetClassObject call, I get an ERROR_NO_INTERFACE message 0x80004002. AND a second .EXE is loaded.
Thanks for the help,
Bill
|
|
|
|
|
If you use ATL, Check CComModule::RegisterClassObject call. In your WinMain function , _Module.RegisterClassObject. Check the second parameter - is REGCLS_SINGLEUSE ? If is so , the class factory will be accesible only for one client at a time.
|
|
|
|
|
Have you considered using the GIT or ROT? Singleton won't work because S1 and S2 are seperate processes any data in A won't be shared.
Bill Wilson wrote:
We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today.
Ah, testing.
|
|
|
|
|
Solon's suggestion put me on the right track. There are 3 modes in which to register:
REGCLS_SINGLEUSE (obvously wrong)
REGCLS_MULTIUSE (I ghought this one would work for me)
REGCLS_MULTI_SEPARATE (Its THIS ONE!!)
This is the one to use if you want multiple clients to share the same instance of the server. The use of the word SEPARATE fooled me into not realizing that if I wanted them to use the same server, I should use the SEPARATE option. lol.
Thanks for the help,
Bill
|
|
|
|
|
I would like to automate Outlook Express for a dialog app in VC++ 6.0/.NET? I have found code for Outlook 2000 but I have it but hate it and this program will only be on my computer.
Thank you.
Real World Coding:
POP& BuyAPop(Money ADollar){...};
|
|
|
|
|
Unfortunately, Outlook Express cannot be automated. However, if all you want to do is automate the process of sending and receiving e-mails then there are many classes here at the CodeProject which might act as a starting point.
Edd Porter
http://www.mideddis.co.uk
|
|
|
|
|
Is it possible to add/set a transparent colour to a bitmap in a dialog bar?
.NET or not .NET? MFC is the question......
|
|
|
|
|
Watcha Folks,
I’m trying to find a way to monitor socket connections on a local machine, in particular to know how many sockets are open, and which ports their assigned to (even better would be to know which application is using which socket!). Does anyone have any idea how I can accomplish this?? Or if its even possible?
Dylan
Software Engineer
|
|
|
|
|
Have you tried netstat ( netstat.exe ) ?
|
|
|
|
|
Take a look at TCPView at www.sysinternals.com
Chris Hafey
|
|
|
|
|
I have been trying to terminate a thread I started in my application. I am writing a server application and have spun a seperate thread off for the server, that in turns spawns another thread when a client connects, and I am using Winsock 2.2. During the listen portion of the server thread I put it in a while loop more specifically:
while(1)
{
}
However, I get a memory leak when I quit the application, since it is in a while loop the thread can not properly terminate. I have tried several methods in order to get it to terminate. Here is what I have tried:
In my ThreadParam struct I added a variable bool Stop. When I start the thread I set stop to false and in the while loop I use an if statement to check for Stop. If it is true I break out of the while loop so the thread can close safely. I change Stop to true in the WM_CLOSE message of the MAIN GUI interface--No success.
Tried using a loop in the close function to make sure that the thread has stopped by checking the return value of ::GetExitCodeThread and making sure it doesn't return STILL_ACTIVE--No success
Current thoughts:
Even though this is a worker thread as defined by MFC I'm thinking of turning it into a UI thread so I can use PostQuitMessage and send a user defined message to thread to terminate.
Any suggestions to resolving this matter? Thanks in advance for any help.
HomeNuke
----
"Nuke'd Your Home, Yet?"
Run your own PostNuke based web server from home
http://www.homenuke.com
|
|
|
|
|
Sounds like you're on the right track - just mumbling here...
Got a Sleep(...) in you're thread loop?
Check for slightly more than STILL_ACTIVE in your shutdown?
do
{
::Sleep(100);
bResult = ::GetExitCodeThread(m_pMyThread->m_hThread, &dwExitCode);
} while (dwExitCode == STILL_ACTIVE && bResult);
Do you have an accept socket blocking? Kick it off with a localhost connect.
...end mumble.
|
|
|
|
|
Wait for the child thread before leaving the main thread - if you do that in a thread with UI don't forget to pump messages :
.......
child thread signal exit
.....
//wait for child
while( WAIT_OBJECT_0 != ::WaitForSingleObject( hThreadChild, 10))
{
MSG msg;
while( ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage( &msg);
DispatchMessage( &msg);
}
}
|
|
|
|
|
- If your working thread has called accept(socket,..) and is currently
waiting for a connection, you may close the socket (closesocket(socket)
to force it to return.
- In OnClose() function, you need to call closesocket(m_ThreadParam->socket)
- You may want to add this new member "socket" in your ThreadParam struct
Good luck!
- Greatest invention : "The Microchip!"
|
|
|
|
|
Thanks to all of you. I will try this when I get home. I just hate when you are running your app in debug mode and as soon as the application stops you get a "Memory leak detected" in your debug window
Especially since this is a server application I don't want to many memory leaks going on, throught the course of the day it may kill the server, even though at this time the app only generates one thread for the server function, but it generates multiple threads for each connection...
Thank you, and I will try all of your suggestions when I get home. However, if anyone has more advice I'm am still open to hearing them.
HomeNuke
----
"Nuke'd Your Home, Yet?"
Run your own PostNuke based web server from home
http://www.homenuke.com
|
|
|
|
|
"In my ThreadParam struct I added a variable bool Stop. When I start the thread I set stop to false and in the while loop I use an if statement to check for Stop. If it is true I break out of the while loop so the thread can close safely. I change Stop to true in the WM_CLOSE message of the MAIN GUI interface--No success."
Why doesn't it work? Most likely your code to check the bool value was not executed because the worker thread was blocking (waiting for other things). There is no way to terminate a worker thread within itself effectively. If you have the thread handle, you can call TerminateThread from outside, but there are warnings against using TerminateThread (see MSDN).
User interface thread is different because it has a message pump, so it can process the quit message. But it changes the way your program works.
|
|
|
|
|
"In my ThreadParam struct I added a variable bool Stop. When I start the thread I set stop to false and in the while loop I use an if statement to check for Stop. If it is true I break out of the while loop so the thread can close safely. I change Stop to true in the WM_CLOSE message of the MAIN GUI interface--No success."
First thing that popped into my head was "is 'Stop' a volatile variable and is it a managed resource? (Do you use a critical section to control who is accessing it? Suggestion: If this is how you want to stop your thread this could work. I would recommend using a short instead of a bool. This way it can have states. Ie. 0=Thread running, 1=Request a stop and 2=Thread stopped. Then you GUI thread can check this before actually closing the window.
Second thing that popped into my head is that Stop shold work uness the code you are using in your while loop is blocking and thus never checking Stop.
Matt Gullett
|
|
|
|
|
Just clarifying the acutual code in the while loop now is:
listen(sListen, 5);
while (1)
[
if (pThreadData->Stop)
break; //Just exit the while loop and let the thread close out
]
closesocket(sListen);
WSAcleanup();
return 0;
It is just bare minimum because I'm trying to see why I get the memory leak. I have nothing else in the while loop pertaining to the socket.
HomeNuke
----
"Nuke'd Your Home, Yet?"
Run your own PostNuke based web server from home
http://www.homenuke.com
|
|
|
|
|
There's no reason for your thread to block with your example except
that your thread is taking up all the CPU. Try putting a Sleep(0) in your
loop. Make sure your memory leak is not from "pThreadData"
- Greatest invention : "The Microchip!"
|
|
|
|