|
Thanks but...maybe I said it wrong, I talked about connection oriented socket, not UDP.
|
|
|
|
|
Hi i tried to reduce my memory leak.I reduced that,but still only few bytes of memory leak.I checked everything,but still i cant find.Pl anybody can help.Thanks in advance.
HRESULT hr;
IXMLDOMDocument2 *pIXMLDOMDocument2=NULL;
IXMLDOMNodeList *pIXMLDOMNodeList=NULL;
IXMLDOMNode *pIXMLDOMNode=NULL,*pIXMLDOMNode1=NULL;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap1 = NULL;
VARIANT_BOOL boolvalue;
long Tablelen;
CComVariant Tablename;
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&pIXMLDOMDocument2);
CComVariant varValue="testing.xml";
if (FAILED(hr))
return(hr);
if(SUCCEEDED(hr))
{
hr=pIXMLDOMDocument2->load(varValue,&boolvalue);
pIXMLDOMDocument2->selectNodes((_bstr_t)"DATABASE/TABLE[@Left]",&pIXMLDOMNodeList);
pIXMLDOMNodeList->get_length(&Tablelen);
HWND hListBox=GetDlgItem(hDlg,IDC_LIST);
pIXMLDOMNodeList->reset();
for(int i=0;i< Tablelen;i++)
{
pIXMLDOMNodeList->get_item(i,&pIXMLDOMNode);
pIXMLDOMNode->get_attributes(&pIXMLDOMNamedNodeMap1);
pIXMLDOMNode->Release();
pIXMLDOMNode=NULL;
pIXMLDOMNamedNodeMap1->getNamedItem((_bstr_t)"Name",&pIXMLDOMNode1);
pIXMLDOMNode1->get_nodeValue(&Tablename);
SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)(char *)(_bstr_t)Tablename);
pIXMLDOMNode1->Release();
pIXMLDOMNode1=NULL;
pIXMLDOMNamedNodeMap1->Release();
pIXMLDOMNamedNodeMap1=NULL;
}
CHECK_AND_RELEASE(pIXMLDOMDocument2);
CHECK_AND_RELEASE(pIXMLDOMNode1);
CHECK_AND_RELEASE(pIXMLDOMNodeList);
CHECK_AND_RELEASE(pIXMLDOMNode);
CHECK_AND_RELEASE(pIXMLDOMNamedNodeMap1);
}
CoUninitialize();
|
|
|
|
|
Jesus!!! Does this code work???
<br />
(_bstr_t)"DATABASE/TABLE[@Left]"<br />
What is this? Never, never do like this. Do:
<br />
_bstr_t(OLESTR("DATABASE/TABLE[@Left]"))<br />
<br />
pIXMLDOMNode->Release();<br />
pIXMLDOMNode=NULL;<br />
It's not bad, but pIXMLDOMNode = 0 is enough.
<br />
(LPARAM)(char *)(_bstr_t)Tablename<br />
Should be:
<br />
reinterpret_cast<LPARAM>(static_cast<TCHAR*>(_bstr_t(Tablename)))<br />
Such a bad cast should be explicit.
<br />
pIXMLDOMNode->get_attributes(&pIXMLDOMNamedNodeMap1);<br />
You are working with very smart pointer. Instead, do like this:
<br />
pIXMLDOMNamedNodeMap1 = pIXMLDOMNode->attributes;<br />
What is:
<br />
CHECK_AND_RELEASE(pIXMLDOMDocument2);<br />
May be it a:
<br />
#define CHECK_AND_RELEASE(x) x->AddRef()<br />
I don't know.
Summary.
1. Never, never use c-casts (like (_bstr_t)x, (LPARAM)y, etc). They are the worst evil, unless you damn sure that you do. It's very hard to find a bug in a such code.
2. Read about _com_ptr_t. Learn how it's intended to use.
3. Avoid macros.
4. Optional, but strongly recommended. Get a Stroustrup.
|
|
|
|
|
Hello,
I have programmed a dialog based application and now i want to add a nice jpg image in the dialog.
Does someone know a simple way? Or does someone know a place where i can download a Control, which i can add to my project.
Thank you,
Willem
Sorry for my bad english..
|
|
|
|
|
This may be of some use,
http://www.codeproject.com/bitmap/cximage.asp[^]
Michael
"I've died for a living in the movies and tv.
But the hardest thing I'll ever do is watch my leading ladies,
Kiss some other guy while I'm bandaging my knee."
-- The Unknown Stuntman
|
|
|
|
|
|
hi
is there a way to copy a file to the same directory and renaming the file all in one. I've tried CFile::Copy, then rename, then copy again, but it seems a bit clumsy...
Thanks
|
|
|
|
|
Adrian2 wrote:
is there a way to copy a file to the same directory and renaming the file all in one. I've tried CFile::Copy, then rename, then copy again, but it seems a bit clumsy...
What exactly do you want to accomplish? Say you have a folder :- c:\abc. Now say you have a file one.gif. You want to copy c:\abc\one.gif to c:abc\two.gif and then rename one.gif to something else??? Is that what you want to do? If so, copy abc.gif to one.gif. Now rename abc.gif to whatever.gif! Pardon me if I misinterpreted your requirement.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
jip
c:\file1.txt must become c:file2.txt
|
|
|
|
|
|
Or use ShFileOperation, which I think let you move/copy files when they are open.
|
|
|
|
|
I'm preparing to develop a web stress testing software.Could someone give me some advices, such as how to realistically reproduce multiple
browsers requesting pages from a web application, what technologies should we adopt...
Our software is aiming to realize three main fonctions:
1. simulate a request to the web server, and trace the process, in order to see if the web
application works normally. If there is a problem, we could know where is it. web server?
database? etc
2. automatize the test, that means to set the test automatically executed in a fix time.
3. simulate multiple users send the request to a website simultaneously, to verify if the web
application works properly under a given enough great number of users.
Thanks a lots!
rick
LOVE LING
|
|
|
|
|
ricklau wrote:
3. simulate multiple users send the request to a website simultaneously, to verify if the web
application works properly under a given enough great number of users.
This can be done using multiple threads. Start n threads and get them all to attack a particular portion of the web site at the same time.
ricklau wrote:
2. automatize the test, that means to set the test automatically executed in a fix time.
You can either feed in a predefined set of URLs. Or you can parse the URLs in a web page and go to each of them automatically. And you'd also have to populate the form text and other fields with random data (sounds rather like a lot of work to me).
ricklau wrote:
1. simulate a request to the web server, and trace the process, in order to see if the web
application works normally. If there is a problem, we could know where is it. web server?
database? etc
I doubt if you can locate the error precisely. It might be a db error but the error might be due to buggy server side scripting.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
|
Hi there,
I want to capture screenshot as well as keystrokes pressed in DOS mode. I have worked on Windows API for achieving these results. It is working fine in case of windows application. I just want to know why it is not happening in DOS promp mode. Is there anyway to achieve this.
I need expert guidance from all of you before reaching any conclusion on this part.
Thanks in advance,
Shitij.
|
|
|
|
|
Hi there,
I want to capture text and password field for an active window. Is there anyway to achieve this.
Thanks in advance,
Shitij.
|
|
|
|
|
|
You probably didn't googled before posting.
MS free stress tools[^]
http://webtool.rte.microsoft.com/comparison.htm
http://www.paessler.com/WebStress/webstress.htm
...
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I just write this code in my initdialog of my dialogbox.so whenever i open this code,the memory size is increased.iam writing this code in win32application.Not an MFC Code.What might be the reason for memory leak above.
IXMLDOMDocument* pXMLDoc=NULL;
IXMLDOMNamedNodeMap* pXMLNamedNodeMap=NULL;
IXMLDOMNodeList* pXMLNodeList=NULL;
IXMLDOMNode* pXMLAttNode=NULL;
IXMLDOMNode* pXMLNode=NULL;
HRESULT hr;
CComBSTR bstrName;
CComVariant varValue;
CComVariant varNodeValue;
long lCount;
VARIANT_BOOL bIsSuccessful;
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&pXMLDoc);
if (FAILED(hr))
return(hr);
if(hr)
{
pXMLDoc=NULL;
pXMLDoc->Release();
}
CoUninitialize();
|
|
|
|
|
suresh_sathya wrote:
pXMLDoc=NULL;
pXMLDoc->Release();
This does not only produces a memory leak, it also does a very nice GPF! since you are using a null pointer to call Release().
So, first of all, pXMLDoc->Release() must be called before pXMLDoc=NULL;
Otherwise, it does not make much sense to use raw interfaces here, just use CComPtr<IXMLDOMDocument> pXMLDoc; instead. It will even release the object for you.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I am just trying to parse xml and add some attribute names to my listbox.But when the program comes in for loop,it stops at third line and shows memory error.
Debug assertion failed
CComPtr<ixmldomdocument> pXMLDoc;
CComPtr <ixmldomnamednodemap> pXMLNamedNodeMap=NULL;
CComPtr <ixmldomnodelist> pXMLNodeList=NULL;
CComPtr <ixmldomnode> pXMLAttNode=NULL;
CComPtr <ixmldomnode> pXMLNode=NULL;
HRESULT hr;
CComBSTR bstrName;
CComVariant varValue;
CComVariant varNodeValue;
long lCount;
VARIANT_BOOL bIsSuccessful;
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&pXMLDoc);
if (FAILED(hr))
return(hr);
varValue="testing.xml";
hr=pXMLDoc->load(varValue,&bIsSuccessful);
pXMLDoc->selectNodes((_bstr_t)"DATABASE/TABLE[@Left]",&pXMLNodeList);
long Tablelen;
pXMLNodeList->get_length(&Tablelen);
HWND hListBox=GetDlgItem(hDlg,IDC_LIST);
CComVariant Tablename;
for(int ii=0;ii< Tablelen;ii++)
{
pXMLNodeList->get_item(ii,&pXMLNode);
pXMLNode->get_attributes(&pXMLNamedNodeMap);
pXMLNamedNodeMap->getNamedItem((_bstr_t)"Name",&pXMLNode);
pXMLNode->get_nodeValue(&Tablename);
//SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)(char *)(_bstr_t)Tablename);
}
|
|
|
|
|
There are many errors in this code. The best option is you get your hands on a working msxml sample first (download msxml 3 SDK, or msxml4 SDK, or platform SDK core services).
For instance, this article [^]on codeproject does such things.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
I wanted to display 10 bitmaps using CImageList
but why all the bitmaps were black
1.first ,I created a project "Cards",Imported 1,2,...,10
2.and I added variable in CCardsView
CImageList* m_pImageList
and the function
BOOL CCardsView::AddBitmap(UINT nResourceID)
{
CBitmap m_bmp;
if(m_bmp.LoadBitmap(nResourceID))
{
m_pImageList->Add(&m_bmp,RGB(256,256,256));
m_bmp.DeleteObject();
return TRUE;
}
return FALSE;
}
3.CCardsView::CCardsView()
{
// TODO: add construction code here
m_pImageList=new CImageList;
m_pImageList->Create(71,96,ILC_COLORDDB,256,1);
for(int i=1;i<11;i++)
{
AddBitmap(i);
}
}
4.CCardsView::~CCardsView()
{
if(m_pImageList!=NULL)
{
delete m_pImageList;
}
}
5.void CCardsView::OnDraw(CDC* pDC)
{
CCardsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPoint pos(0,0);
// m_pImageList->SetBkColor(CLR_NONE);
// m_pImageList->SetOverlayImage(0,1);
for(int i=0;i<10;i++)
{
m_pImageList->Draw(pDC,i,pos,ILD_NORMAL);
pos.x+=50;
}
}
Why?
--oly--
|
|
|
|
|
RGB(256,256,256) is like RGB(0,0,0). Max channel value is 255.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
hi,
this is the debug result:
f:\projects center\task history\mission 8_13\hydrosrv\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
and this is the source of warning:
enum RecordCreateOptionsEnum
{
adCreateCollection = 8192,
adCreateStructDoc = -2147483648,
adCreateNonCollection = 0,
adOpenIfExists = 33554432,
adCreateOverwrite = 67108864,
adFailIfNotExists = -1
};
tell me how to fix this problem.
Thanks in advance
Extreme programming. Do the No.1
|
|
|
|
|