|
I'm not copying all my code but the InsertItem() functions are here:
proc=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br />
<br />
info=new PROCESSENTRY32;<br />
info->dwSize=sizeof(PROCESSENTRY32);<br />
int id=0;<br />
<br />
Process32First(proc,info);<br />
m_list1.InsertItem(0,(LPCTSTR)info->szExeFile);<br />
<br />
while(Process32Next(proc,info)!=FALSE){<br />
id++;<br />
m_list1.InsertItem(id,(LPCTSTR)info->szExeFile);<br />
}<br />
<br />
CloseHandle(proc);
This here was too only a segment of the code...
|
|
|
|
|
Assuming your list control had another column:
int x = m_list1.InsertItem(0,(LPCTSTR)info->szExeFile);
sprintf(szProcId, "%lu", info->th32ProcessID);
m_list1.SetItemText(x, 1, szProcId);
Otherwise, you'll need to use:
int x = m_list1.InsertItem(0,(LPCTSTR)info->szExeFile);
LPDWORD lpProcId = new DWORD;
*lpProcId = info->th32ProcessID;
m_list1.SetItemData(x, lpProcId);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks, it really helped me out, now i'm executing MSPAINT and NOTEPAD to terminate them...
|
|
|
|
|
How to restore minimized window?
I did so:
and it was not succeded -Why?
<br />
pDlg->ShowWindow(SW_SHOW);<br />
pDlg->SetFocus();<br />
<br />
WINDOWPLACEMENT wndpl;<br />
pDlg->GetWindowPlacement(&wndpl);<br />
<br />
wndpl.length = sizeof(wndpl);<br />
wndpl.flags = WPF_SETMINPOSITION ;<br />
wndpl.showCmd= SW_SHOWMAXIMIZED | SW_SHOW;<br />
<br />
pDlg->SetWindowPlacement(&wndpl);<br />
<br />
<br />
pDlg->UpdateWindow();<br />
thanks.
|
|
|
|
|
vgrigor wrote:
How to restore minimized window?
ShowWindow(SW_RESTORE);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
Hello,
I am having some difficulty using the CArchive socket class in a storing (output) situation. My problem is with the m_pArOut pointer in the following code. It seems that for some unknown reason I am unable to write using the CArchive. Here is a code snippet:
----------------------------------------------------------------
<>
sockClient.Create();<br />
sockClient.Connect("192.168.1.112",3030);<br />
<br />
file = new CSocketFile(&sockClient);<br />
<br />
m_pArIn = new CArchive(file,CArchive::load);<br />
m_pArOut = new CArchive(file,CArchive::store);<br />
<br />
*m_pArOut<<"This is a test";
----------------------------------------------------------------
<>
CSocket sockClient;<br />
CSocketFile* file;<br />
<br />
CArchive* m_pArOut;<br />
CArchive* m_pArIn;
----------------------------------------------------------------
When this code is executed I do not receive the message “This is a test” on my server. However, if I change the code to use a local version of the CArchive object like the following it works:
----------------------------------------------------------------
CArchive arOut(file,CArchive::store);<br />
m_pArOut = &arOut;
----------------------------------------------------------------
The user of the pointer m_pArIn works in every case. I don’t understand why it would work when locally instantiated. I also don’t understand why the same problem doesn’t exist for the input archive.
Thank you for your help
Brian
|
|
|
|
|
I'm a bit of a beginner, but if I were you, I'd try flushing the output after you send "This is a test";
m_pArOut->Flush();
Hope this works for you!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
Thanks for the reply Doug. I too am new to VC++. I usually program in straight C in UNIX or VxWorks OS.
I tried flushing before, but no dice. It is the strangest thing, since it works if the object is instantiated locally.
Thanks again
Brian
|
|
|
|
|
hi,
up to now spy++ worked great, but from one moment to the other it won't display dispatched messages... and that happens with every program i want to spy!
Can somebody imagine what's wrong ?
Thanks in advance!
|
|
|
|
|
I'm still new to c++ so please bare with me.
I'm using the ShellExecuteEx in MFC to open a Acrobat .pdf document.
When Acrobat is closed after the document has opened or the process is closed I want to remove the file from the Directory.
my code looks like this.
<br />
char pathBuffer[MAX_PATH];<br />
char szCurrDir[MAX_PATH];<br />
<br />
GetCurrentDirectory(MAX_PATH,szCurrDir);<br />
GetTempFileName (szCurrDir, "", 0, pathBuffer);<br />
CString stmpfile = pathBuffer;<br />
<br />
SHELLEXECUTEINFO si;<br />
memset(&si, 0, sizeof(si));<br />
si.cbSize = sizeof(si);<br />
si.hwnd = this->m_hWnd;<br />
si.lpVerb = "open";<br />
si.lpFile = pathBuffer;<br />
si.nShow = SW_NORMAL;<br />
si.hInstApp = NULL; <br />
si.fMask = SEE_MASK_NOCLOSEPROCESS;<br />
int res = ShellExecuteEx(&si);<br />
if (res==1)<br />
WaitForSingleObject(si.hProcess,INFINITE);<br />
<br />
<br />
CloseHandle(si.hProcess);<br />
<br />
<br />
remove(stmpfile);<br />
When there is no instance of Acrobat running it works fine. But as soon as Acrobat is already running or an instance of the Acrobat exe still in the process tray it doesn’t seem to open the .pdf document.
I cannot use the ShellExecute structure for the simple reason that I need to know when Acrobat is closed so that I can remove that file from the directory.
The ShellExecute will open the Acrobat document regardless of whether there an instance is of Acrobat running.
//ShellExecute(this->m_hWnd,"open",pathBuffer, NULL, NULL, SW_SHOWNORMAL);
Any help would really be appreciated.
|
|
|
|
|
See if this helps:
WaitForSingleObject(si.hProcess, INFINITE);<br />
CloseHandle(si.hProcess);<br />
remove(stmpfile);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The WaitForSingleObject function halts program execution temporarily. This function allows a program to wait until something else has happened before execution continues.
The CloseHandle(si.hProcess); will thus in this case only execute after Acrobat is closed.
|
|
|
|
|
My biggest problem is why does the file not open with the ShellExecuteEx()structure when there is already an instance of Acrobat running, where as the ShellExecute() opens the document when there is already an instance of acrobat running.
Could it be due to the handle or process that has beed created to Acrobat using the ShellExecuteEx() structure? Where as ShellExecute() does not.
|
|
|
|
|
I'm aware of this, but you are still responsible for closing the process handle when using the SEE_MASK_NOCLOSEPROCESS flag. See the documentation!
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
I got the folowing error while running a VC++ program. This program was complied on Debug mode.
====================
Error:-
Debug Assertion Failure.
Program: C:\Saurabh_Server.exe
File: dumpout.cpp
Line: 52
====================
This might be because of some memory leaks. Bcoz if these errors were due to Assertion failures in my code files, then error msg would have displayed my file name and line no itself.
But the file specified here does not belong to me.
I complied this program under "Release" version and it runs absolutely fine. Now my question is:
1. If I continue working on this code and at the end compile it to Release version, will it be Ok. Will it cause any error in future if user works on the Release version generated .EXE? Or this needs to be fixed immediately.
2. How it is to be fixed. Can anybody suggest the approach for it. (also for resolving the memory leaks).
Thanx and Regards,
Saurabh
|
|
|
|
|
Saurabh_Delhi wrote:
If I continue working on this code and at the end compile it to Release version, will it be Ok.
No.
The error will just go unnoticed. Maybe it will manifest itself under mysterious circumstances, or you will find a way to trigger.
Saurabh_Delhi wrote:
How it is to be fixed
How are we to know?
You did not show the relevant code.
Saurabh_Delhi wrote:
also for resolving the memory leaks
Delete every memory you allocate exactly once.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Thanx jhwurmbach.
But somebody told me that Debug Assertion errors does not comes under Release Version EXE. And so is happening with me. I am not getting any error in Release version EXE. If so is the case, then I can fix them later.
The code is comprised of many files so I can not post them here.
Is there any tool available to find memory leaks.
Regards,
Saurabh
|
|
|
|
|
Saurabh_Delhi wrote:
Debug Assertion errors does not comes under Release Version EXE
This is true. ASSERT in release builds is defined as 'nothing'.
The errors will not show up as an error, but they are there nonetheless. You just don't see them.
Or at least not in the beginning. You can never be sure that they will not come up later.
Not asserting does not mean that the error is magically fixed - it just turned off the error detection in the routine you called.
Saurabh_Delhi wrote:
Is there any tool available to find memory leaks
Yes. BoundsChecker springs to mind. But it is expensive, requires good knowledge and does not find every bug.
There may be others, even here at CP. Please use the 'search' facility.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Saurabh_Delhi wrote:
But somebody told me that Debug Assertion errors does not comes under Release Version EXE.
While it is true that assertions do not fire in release mode, the condition(s) that would have caused them to fire still exist.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Saurabh_Delhi wrote:
But the file specified here does not belong to me.
Which file does not belong to you, Saurabh_Server.exe or dumpout.cpp?
Saurabh_Delhi wrote:
If I continue working on this code and at the end compile it to Release version, will it be Ok.
If only errors were that easy to eliminate! An error is an error and will persist, regardless of whether the code is compiled in debug or release mode.
Saurabh_Delhi wrote:
...(also for resolving the memory leaks).
There are several ways of doing this. When your program is compiled in debug mode and you run it via F5, if any memory remains allocated (assuming the new operator was used, the results of such will show up in the debug window. Also, check out the CMemoryState class, and _CrtDumpMemoryLeaks() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
http://www.codeguru.com/forum/showthread.php?s=&threadid=265744
|
|
|
|
|
Ok?? Are you showing us that you posted the same question to another forum, or that you got more of the same answers, or that the problem is now resolved?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hi
I need to know where i can find some code to study thru
iv'e looked but only finds snippets i want like complete
applications that i can study and work thru
they say its a good thing to do
regards
|
|
|
|
|
have a look at all the linux/bsd programs, and at some of the other freeware software out there.
http://sourceforge.net/[^] is a place to look for applications with source code.
There a a couple of windows applications available on sourceforge.
Have fun.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|