|
rajandpayal wrote: What is making this not to work?
It's not designed to work that way. You're doing nothing wrong. See here for more on reference counts, address spaces, etc.
Perhaps if you explained what you're ultimately after, someone could offer an alternative solution.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
We are seeing some memory leaks in our apps which are getting difficult to track down
even with using various tools like purify, boundschecker. mem validator etc..
I was actually trying to see if just by releasing a particular (from another dll in that process) dll, it helps..
But I realize that it wont help much since memory leaks usually result from we not freeing up heap allocations... And heap is process wide..
|
|
|
|
|
rajandpayal wrote: We are seeing some memory leaks in our apps
If you have memory leaks, forcing the DLL to close will not keep the memory leaks from happening (after all, the memory has already leaked at that point). You have to find the place(s) where you're not freeing up a pointer. Running the DLL under the debugger (assuming you have the source code for the DLL) should indicate a general location where the memory leaks are occurring.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Are there any functions that when given an error number returned from WSAGetLastError() and GetLastError() will return a char * to a descriptive string for that error. I am using unmanaged C++. This is what I would like to be able to do:
cout << strerror(WSAGetLastError()) << endl;
-- modified at 16:57 Monday 11th June, 2007
|
|
|
|
|
Check out FormatMessage() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hdcX holds an image consisting of two colors (say black and white). You can BitBlt to hdcX as a destination. However, you cannot BitBlt *from* hdcX as a source. You cannot select a pattern (hbitmap) brush into hdcX either (although you can select a solid brush). Also, hdcX does not support floodfill.
You want to BitBlt hdcA to only the white areas of hdcX, and hdcB to only the black areas of hdcX.
How do you do it.
-- modified at 16:29 Monday 11th June, 2007
|
|
|
|
|
I don't think you can do it directly. You'll probably need at least one extra bitmap and the use of MaskBlt. Have fun
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I have variable that stores hwnd of a particular windows. I want to retrieve path to the executable file that created this window. How can I do it? I'm not very much familiar with winapi so I think the steps are to retrieve the process that created the window and then executable path. Is there any other way to do it? what function will I need? Thanks
|
|
|
|
|
For NT 4.0+ this combination of APIs may help...
#include <psapi.h>
...
DWORD dwProcessId;
::GetWindowThreadProcessId(hwnd, &dwProcessId);
HANDLE hProcess = ::OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
TCHAR szPathname[MAX_PATH];
::GetModuleFileNameEx(hProcess, NULL, szPathname, MAX_PATH * sizeof(TCHAR));
::CloseHandle(hProcess);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks I'll try it but I will have to convert that to c# first.
After posting this I found GetWindowModuleFileName Function which takes in hwnd of the window and return the full path and file name of the module associated with the specified window handle so can it be solution?
|
|
|
|
|
Giorgi Dalakishvili wrote: After posting this I found GetWindowModuleFileName Function
Looks easier than my method!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Giorgi Dalakishvili wrote: but I will have to convert that to c# first
The System.Diagnostics namespace has the Process and ProcessModule classes but I don't see
a process-from-window method...
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: The System.Diagnostics namespace has the Process and ProcessModule classes
Yes I'm aware about them but I will have only hwnd and I don't think I'll be able to solve the problem without winapi
|
|
|
|
|
Cool. Thanks for pointing out the GetWindowModuleFileName() API!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have an application which needs to upgrade firmwares of home routers automatically. I sniffed the outside packets when I click "upgrade" button and put everything I got in the code and do an HTTP Post function(not API. It works for other senario.). But it does not work. My question is why it does not work and how to make it work. Is it because HTTP protocol does not allow file upload like this? I have to have a web browser or email application to assist the file uploading?? Please advise me.
My code looks like this:
virtual int UpgradeFirmware(CString firmwareImage, CString RouterIP, CString Username, CString Password)
{
CString url = "http://" + RouterIP + "/upgrade.cgi";
CString ref = "http://" + RouterIP + "/Upgrade.htm";
CString request = "-----------------------------7d71f91e504ea";
request += "\nContent-Disposition: form-data; name=\"UpgradeFile\";";
request += " filename=\"C:\\firmware\\Netgear WGR614 V2\\wgr614v3_v2_16rc4.chk\"";
request += "\nContent-Type: application/octet-stream";
request += "\n-----------------------------7d71f91e504ea--";
CString page = HTTPPost(url, request, Username, Password, ref);
if(page.Find("Settings are successful.")>0)
return 0;
}
capulett
|
|
|
|
|
capulett wrote: CString page = HTTPPost(url, request, Username, Password, ref);
At this point, are url , request , and ref exactly how you expect them to be (e.g., commas, dashes, spaces, slashes)?
Does HTTPPost() return any sort of fail/success indicator?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for replying.
Yes, the url, request, and ref are exactly how I expect them to be. In my application, I use url, ref, request, and HTTPPost() very often to do some other operations. Only the updatefirmware operation fails. I suspect it has something to do with the file uploading. But I don't have any experience of it.
From the network sniffer, there is some mess following:
Content-Type: application/octet-stream.
It's the file which is uploaded. But I cannot put it in my code and it won't be right to put the messy stuff in the code. Do I need a way to uplode the file other than HTTPPost()?
Usually the HTTPPost() returns nothing. But it should return something indicates the upgrade is in progress...
I really don't know how to solve this. I will appreciate your help. Thanks a lot.
|
|
|
|
|
Dear Sir,
This Class help me very much.
But I want now to have a personal header(Name of society, date and so on) on my Excell Sheet.
How can I do So that my hearder line of fields begin in the 5th line for example.
I learn My self
|
|
|
|
|
Did you consider asking your question here?
mikobi wrote: But I want now to have a personal header(Name of society, date and so on) on my Excell Sheet.
So can't you just assign values to those cells?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How do I get to know read individual lines from a multiline edit control?
Let me know the chunk of code. I do know of windows API to achieve the same.
|
|
|
|
|
tom groezer wrote: llinelength = ::SendMessage(hwnd, (UINT) EM_GETLINE, index, (LPARAM)(LPCTSTR)buffer);
What is index ?
tom groezer wrote: Now I have to use the a call to SendMessage with EM_GETLINE. How do I do that?
What exactly is your question: how to use the return value of EM_GETLINECOUNT , or how to send the EM_GETLINE message?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is the way i have implemented to read the lines from edit control.
LRESULT l_numEvents = ::SendMessage(hwnd, (UINT)EM_GETLINECOUNT, 0, 0);
LRESULT llinelength = ::SendMessage(hwnd, (UINT)EM_LINELENGTH, index, 0); index = 0 for first item
llinelength = ::SendMessage(hwnd, (UINT)EM_GETLINE, index, (LPARAM)(LPCTSTR)tbuffer);
I'm not able to execute the last staement properly.
MSDN says that the last parameter is "A pointer to the buffer that receives a copy of the line. Before sending the message, set the first word of this buffer to the size, in TCHARs, of the buffer. For ANSI text, this is the number of bytes; for Unicode text, this is the number of characters. The size in the first word is overwritten by the copied line.
How do I achieve what is mentioned in italisized code.
|
|
|
|
|
Wouldn't it make more sense to just send the control a WM_GETTEXT message? You can then parse the buffer (as individual lines) as necessary.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How do I parse independent lines? is it something ot do with \r\n
|
|
|
|
|
It could be \r or \n or a combination of both.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|