|
The HINSTANCE returned by ShellExecute is not a valid handle to anything, it is there for compatibility reasons. To obtain a true handle to the launched process, use ShellExecuteEx . Nevertheless, for the purposes of closing the process, it is better to have the process ID, which you can obtain easily if you launch the program with CreateProcess (retrieving the process ID from a process handle is alas no easy task). Given the process ID of the program you wish to close, use EnumWindows to enumerate all top level windows and proceed as follows for each HWND enumerated:- Use
GetWindowThreadProcessId to retrieve the process ID of the window. - If the process ID matches the one you got, then send a
WM_CLOSE message to that window. For added robustness, you might consider using SendMessageTimeout and, if the polite way of closing the app doesn't work, getting a process handle with OpenProcess and calling TerminateProcess to force the app shut.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I got an application from my friend who got it from the net.When I opened it asked me whether to convert it to new version.I pressed "ok".I compiled succesfully but getting the error while linking.It is giving this error and saying that
Linking...
LINK : fatal error LNK1104: cannot open file "c:\devstudio\cppprojects\zip\debug\zipdbg.lib"
Error executing link.exe.
ServerWindow.exe - 1 error(s), 0 warning(s)
How can I remove this error?Do I need any project settings?
Thank you
Pathi
|
|
|
|
|
So "c:\devstudio\cppprojects\zip\debug\zipdbg.lib" is on your c: drive or not?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am just about 1/2 way through a C++ program and have noticed a huge drop in articles in magazines. I was wondering if someone could tell me how relevant a programming degree in CPP is to the newe .NET framework. Is C# just an updated renamed version of C++? I'd really appreciate anyone making me feel better and letting me know that I'm not just wasting my time with a language that may not be around for much longer. These aren't rumors I've heard or anything, it's just my paranoia in me needing some reassurance.
Thanks
|
|
|
|
|
Garry White wrote:
Is C# just an updated renamed version of C++?
No, it's a new language which looks very much like other language which name starts with 'J'.
C++ can be used in .NET via so-called Managed C++ which produces .NET assemblies containing IL.
There's still normal, unmanaged C++ in VS.NET - it creates plain Windows exes and dlls. C++ still remains the most powerful programming language on this planet. It's going to be around for ages to come.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi All,
I'm having some problems with a some threads of mine. The thread in question is called TxThread. During this thread I create a new thread called ListRecThread. The TxThread can be closed before the ListRecThread may be finished, so from the TxThread I try to post a message to the ListRecThread to quit, which the ListRec is checking for.
The ListRecThread gets the Quit message and I return to break out of the loop. I post the quit message from the TxThread using: ListRecThread->PostThreadMessage(WM_QUIT, 0, 0);
and on the next line I have
WaitForSingleObject(ListRecThread->m_hThread, INFINITE);
but once this line executes is says Debug assertion failed followed by a message saying the thread has exited with code 0x3
If anyone has any idea as to what is wrong or if I'm doing something silly here, I'd appreciate any help!
Edit: By the way, the TxThread is in an MFC Extension DLL, could this be causing the problem????
|
|
|
|
|
Since you mention m_hThread, I assume your ListRecThread is a subclass of CWinThread ?
1. Set the m_autoDelete member variable to false in ListRecThread's constructor.
2. Then do WaitForSingleObject( ListRecThread->m_hThread,INFINITE) in TxThread
3. Perform a delete operation on m_listRecThread from TxThread. I assume you have stored a pointer to ListRecThread in TxThread
That ought to work
Hope that helps
|
|
|
|
|
I tried your suggestion but it is still giving me weird errors.
The threads are all appearing to shut down ok as I watch it in the task manager, but once the threads have all closed I am getting Debug Assert errors, memory read errors and unhandled exceptions! Using the debugger I cant find where it is going wrong either and it seems almost random as it sometimes gets a debug assert error on the waitforsingle object for the TxThread.
Oh well I think things have gotten a bit messy so I might have to go back and re-work some stuff!
Thanks anyway
|
|
|
|
|
MarkPQ wrote:
but once this line executes is says Debug assertion failed followed by a message saying the thread has exited with code 0x3
Debug assertion tells you a lot about the problem - check the stack and you'll be able to see what exactly caused the assert to fire.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks for the help,
I found on the call stack that it was a GetAt() call for a CByteArray causing the assertion error. It was then that I realised that in the troublesome thread, it calls several functions that check for quit messages also and return nothing if it is the case. At one point in the thread I had a bug where I checked a CByteArray that if the Quit message was received from the function preceeding . . . would not exist and hence causing the assertion error! Silly me!
Its all fixed now! Thanks for your help! Greatly appreciated!
|
|
|
|
|
Hi,
I have a image loaded form a file through
LoadImage().I will extract the buffer & put into another file(dummy file).When i see the content of the dummy file,the image is looks as it is been fliped vertical.
I mean top portion is placed at the bottom.
Here is bit of code where i write to a dummy file.
CreateFile (the_acFile, GENERIC_READ |GENERIC_WRITE, FILE_SHARE_READ, NULL,OPEN_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL) ;
WriteFile(m_hPreviewFile, in_Buffer, lpbminfo->biSizeImage , &the_BytesWritten, NULL );
Can anyone help me..
Neha
|
|
|
|
|
How are you getting your byte values for the image into the lpbminfo structure? If you are using a function like GetDIBits , it is possible to load the image upside down.
A bottom-up DIB is specified by setting the height to a positive number, while a top-down DIB is specified by setting the height to a negative number.
|
|
|
|
|
I load the image through
where gszPreviewFile is a path to a dib file.
DIBSECTION ds;
hImage = (HBITMAP)::LoadImage (AfxGetInstanceHandle(), gszPreviewFile, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE |LR_CREATEDIBSECTION );
GetObject(hImage, sizeof(BITMAP), &bm);
GetObject(hImage, sizeof(DIBSECTION), &ds);
lpbminfo =ds.ds.dsBmih ;
Buffer i will write to dummy file i will get it from bm.bmbits.
|
|
|
|
|
If i use
GetDIBits(NULL,hImage,1,ds.dsBm.bmHeight ,the_buffer,&bmi,DIB_RGB_COLORS);
It returns me error as 87,INVALID_PARAMETER.
Could anyone pl help me.
Neha
|
|
|
|
|
Hi
i wanna tell VC to stop reporting linker warning LNK4006
symbol already defined in object; second definition ignored
(i'm being a bit lazy with my global (wooo naughty boy using a global )
what #pragma do i use to tell the linker to shut up about it? or do i use something else?
regards
Bryce
|
|
|
|
|
#pragma warning( disable : 4006)
|
|
|
|
|
nope
that turns off the compiler warning
not the linker one
Bryce
|
|
|
|
|
Well in that case there will not be a #pragma to turn off the linker warning.
You can reduce the warning with this switch /WARN[:level] where level is 0-3. The higher the number the higher the number of warnings that you may receive. But I do not know of a way to disable a linker warning.
|
|
|
|
|
Allows selective modification of the behavior of compiler warning messages.
Pragmas won't work I don't think.
You could set the wanring level, but that is not as specific as a pragma i'm afraid.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
A post on the lounge reminded me of something I've been meaning to look up for a while: benchmark tests on .NET.
Does anyone know of any benchmarks available, and, would anyone be interested in porting some standard benchmarks to C#, VB.NET and/or Managed C++?
cheers,
Chris Maunder
|
|
|
|
|
Chris Maunder wrote:
would anyone be interested in porting some standard benchmarks to C#, VB.NET and/or Managed C++?
If it does not involve too much math, I'd be interested.
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
I'm not sure, but keep in mind point 5.9 of the EULA which requires you to get written approval from Microsoft before publishing the results. I don't think that would be a problem for you, but I don't want you to get in trouble because you forgot. I've gotta look after my favorite dev site heh
- Jason
Do you have a Pulse?
SonorkID: 100.611 Jason
Veni, vidi, VC
- I came, I saw, Visual C
|
|
|
|
|
EULA? What's a EULA? <look of sweet innocence>
cheers,
Chris Maunder
|
|
|
|
|
Hi
I am trying to find any example of Console application with CView object as a monitor for the program.
Any ideas ?
Thank you
Gollum
|
|
|
|
|
You'd also need to create a frame window to hold the view window. And manage your message pump. I seriously dont think it's worth the effort.
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|