|
The process must pass in TerminateProcess() a handle, not a filename. If you want to close a certain applicant, then search for the handle to its main window via FindWindow().
Kuphryn
|
|
|
|
|
TerminateProcess takes a handle to a process and an exit code as parameters so your code as written cannot compile.
You can get a handle to a process using OpenProcess given the Process ID which you can see in Task Manager, or enumerate using the ToolHelp functions CreateToolhelp32Snapshot, Process32First and Process32Next .
Alternatively you could look for a 'kill' program, I think there's one in the Resource kit.
Paul
|
|
|
|
|
http://www.physiology.wisc.edu/ravi/software/killproc/
|
|
|
|
|
I have a dialog based application and I have added a CRichEditCtrl to the dialog using the resource editor (incl. a CRichEditCtrl member variable).
Now I am trying to add text to this control if the user clicks on a button.
I have the following code in the message handler of the button:
m_RTFEdit.SetSel(-1,-1);
m_RTFEdit.ReplaceSel(pszData);
But this seems not to work. In the past I used StreamIn to copy text to a rich edit ctrl but now I want to use ReplaceSel.
Is it possible that the CRichEditCtrl loses the focus and so
ReplaceSel can not work?
Thanks in advance for your help.
|
|
|
|
|
Have you tried
m_RTFEdit.SetSel(0,-1);<br />
m_RTFEdit.ReplaceSel(pszData);
Best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Yes and I have also tried
GetSel(start, end);
SetSel(end, -1);
But GetSel returns 0,0 so I think the problem is that the RTF ctrl loses the focus(?)
|
|
|
|
|
I want to make a generic file opening program, A simple dialog with one button. The user clicks on it and it launches the file open dialog.When the user selects a file that file is opened and displayed, whether it is a txt or doc or pdf or .... The function WinExec runs executables, but what about opening and displaying any document? I am using VC++ 6.0.Any solutions?
|
|
|
|
|
look up ShellExecute.
If you provide it with a document's file name, Windows will automatically start the corresponding application, as if you'd double-clickj the file in Windows Explorer.
Flirt harder, I'm a Coder
mlog || Agile Programming | doxygen
|
|
|
|
|
WinExec is a holdover from Windows 3.1 and could be removed in the future. Don't use it.
Instead, consider ShellExecuteEx (which can also launch executables). It will use whatever's configured in the Registry, the same as Explorer does.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
I have an app that loads custom cursors when the user clicks on a toolbar. The cursor is loaded aok but when the user moves the mouse the cursor appearrs to flick. The cursor is preloaded in the view constructor using:
CNote1 = AfxGetApp()->LoadCursor(IDC_NOTE1);
and then updated in the COmmand_UI handler using:
pCmdUI->SetCheck(m_bNote1);
if(m_bNote1 == TRUE) ::SetCursor(CNote1);
anyone knows how to avoid the flickering?
Thanx in advance
|
|
|
|
|
|
hi all, i am using the following code:
CMemDC memDC(&dc);
HBITMAP hBmp = ::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1));
::SelectObject(memDC.m_hDC,hBmp);
memDC.BitBlt(10,10,16,16,&dc,0,0,SRCCOPY);
where CMemDC, is the class where CreateCompatibleDC occurs....
i can see the image perfecly on my dialog, but when i drag the dialog out of the boundaries of the screen and then drag it back in, i see the image has fudged (appears blurry)....
what do i need to do to fix this?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
The scenario your'e describing (shows ok but when i drag out and then into the screen it looks like !@#!@$!) happens when you paint your bitmap just once, and then go on forgetting about it.
Your application receives WM_PAINT/OnPaint messages in order to redraw portions of the screen. If you don't respodn to these messages or respond without drawing your bitmap, your bitmap will end up not being on the screen once the window redraws itself.
so, either add a custom control and have it's OnPaint BitBlt your bitmap, or override your main dialog's OnPaint to draw the bitmap (less nice but still works).
cheers
|
|
|
|
|
hi ohad, thanks for the reply
but that wasn't my problem! i've found out what i was doing wrong....
I did override OnPaint(), and place the bitblt there, but still i got a fudgy image....
the problem was there were suppose to be 3 dc handlers, and i only used 2...why 3? well, 1 for the screen (CPaintDC), 1 for the Memory dc (CMemDC) and one for my image (a totally new DC), as soon as i've put a new DC, problem was solved!
thanks anyway
Cheers right back at ya
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I was writing a keyboard hooking dll, used ::SetWindowsHookEx to obtain a HHOOK , which was 0x0233078B in my case, but when I was done with the hook, for some odd reason ::UnhookWindowsHookEx returned FALSE , and ::GetLastError returned error code ERROR_INVALID_HOOK_HANDLE .
I debugged the code and value of my HHOOK never changed, so how could the handle, 0x0233078B, obtained from a successful ::SetWindowsHookEx call, suddenly become an invalid handle? Any helps are appreciated.
|
|
|
|
|
Hi,
in connection with my Outlook-Automation I´m using an event handler to
catch Outlook events im my application.
Sometimes (when my app sends a request who leads to an exception) I get an
error like this:
RPC Server is not available !
Because my app sends from every 2 minutes messages to Outlook it leads to
an total crash (Outlook and my app)
I would like to catch those Errors which gives me the possibility to react on this events an restart for example the RPCSever.
Can someone please tell me who to implement this ?
Thanks, Christian
|
|
|
|
|
Hai all,
Im planning to do a project which can remotely access a pc. For that i want to find, whether there is any change in the clients display.
But when i hook WM_PAINT, a lot of paint messages are comming even if the machine is idle.
Can anyone tell me an idea to solve this ? thanx in advance.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Have you tried the WM_DISPLAYCHANGE message?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Dear Greeeg,
Thanx a lot for your valuable reply. But one doubt. When i tried to spy the WM_DISPLAYCHANGE message using Spy++, i can't find any WM_DISPLAYCHANGE message generating, when i open/move/close windows. Please clear this doubt.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Unless you are doing this as programming excersize, I could recommend forgetting it. Either use existing tool(RAdmin, NetMeeting, PCAnywhere) for your own needs, or find another tool to create for selling.
Catching image is just a beginning, and if you have problems with it, probably you are not good enough to do it. No offences, I'm also not qualified enough. But you will have to find a way for real-time image differencing and packing. Or did you think you could get enough perfomance by sending full screen/window image over a network? Think again. And finally you will stuck at what a friend of mine did, he made all this path, only to find out that to get true speed he have to develop special screen driver (as far as I understood), which market leaders already have. Otherwise you have speed limit that you will reach by making a screenshot - just consider copying, comparison and packing of 1024x768x16bit = 1.5 Mg image and do it 10-20 times per second.
PS. WM_DISPLAYCHANGE comes when screen resolution changes.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Dear Igor,
Thanks for ur valuable reply. Im just doing this project for improving my knowledge. And now i understood that the full screencapture method was utter foolishness.
And will you please explane that screen driver method, more clearly ? is that hooking the display driver ? or something like that ? Can you please provide me some helpful links about that ?
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
No, sorry, I don't know the details myself. But for your own needs screen capturing is good enough. As far as I could understood, that 'driver' just provide you direct access to screen picture, which let you skip one step from process - preparing and copying picture to intenal bitmap. Still you have to do all differencing and packing yourself.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
okay Igor... Thanx a lot.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
<br />
typedef struct{<br />
char buff[20];<br />
} my_struct;<br />
<br />
my_struct my_arr[1000][30][10][10][3];<br />
<br />
int main(){ <br />
for ( int a = 0; a < 1000; ++a ) <br />
for ( int b = 0; b < 30; ++b ) <br />
for ( int c = 0; c < 10; ++c ) <br />
for ( int d = 0; d < 10; ++d ) <br />
for ( int e = 0; e < 3; ++e ) <br />
{ <br />
my_arr[a][b][c][d][e].buff[0]='0';<br />
my_arr[a][b][c][d][e].buff[19]='9';<br />
}<br />
return 0;<br />
}<br />
In previous thread, I have asked about the problem when using large data. Thanks so much for all of your replying.
I based on yours comment to check my code again and I found that I had a mistake. Yes, the program run normally.
Here I had changed code to another type:
<br />
typedef struct{<br />
CByteArray buff;<br />
} my_struct;<br />
<br />
typedef struct{<br />
my_struct dat[30][10][10][3];<br />
} data;<br />
<br />
CArray<data, data&> my_arr;<br />
In CWinApp::InitInstance():
<br />
int n=1000<br />
my_arr.SetSize(n);<br />
for ( int a = 0; a < n; ++a ) <br />
for ( int b = 0; b < 30; ++b ) <br />
for ( int c = 0; c < 10; ++c ) <br />
for ( int d = 0; d < 10; ++d ) <br />
for ( int e = 0; e < 3; ++e ) <br />
{ <br />
my_arr[a].dat[b][c][d][e].buff.SetSize(1);<br />
}<br />
}<br />
I tested n from 100 to 1000 and CArray seem to be not effective. When n>=500, the program run more slowly. And when n=1000, the system alerted that out of virtual memory.
Please note that the buff size is only 1 (beside 20 in previous version)
In my project, buff size is varying.
n is about 300-800
All remaining size of array are const
Here are my questions:
In this case, which is my best solution (Using CArray or not)?
If anyone has experience in using CArray and processing large data, please give me a hint.
Thank you very much.
|
|
|
|
|
nguyenvhn wrote:
typedef struct{
CByteArray buff;
} my_struct;
typedef struct{
my_struct dat[30][10][10][3];
} data;
CArray<data, data&> my_arr;
From a cursory glance at MFC code, and unless I made a severe mistake:
You are aware that every element in my_arr is of type data , which is holding nine thousand CByteArray's? CByteArray's which each are of size 20 bytes and requires construction, including construction of parent class object CObject? So just one single instance of data at minimum requires 180.000 bytes.
For 'n' in your code you are:
1. Creating m = n * 9000 CByteArray's, for a total of at least m * 20 bytes.
2. Iterating over those m ByteArrays, calling SetSize for them, which allocates at least 16 (or is it 32, I really don't remember the allocation granularity of the SBH) bytes each, for a size of m*16 or m*32 bytes.
This becomes m*(20+16) or m*(20+32) bytes, minimum.
If n=1, you allocate at least 324.000 bytes.
If n=1000, you allocate at least 324.000.000 bytes.
Should SBH allocation granularity be 32, then you would get a memory load of about 446MB just to hold those nine million bytes. Should you use the debug heap, I think you can safely add another m*16 or m*32 bytes (for a memory load between 446 and 720MB respectively).
Just to create the nine million *holders* of the data, not the data itself, for the n=1000 case, you use 180 million bytes.
In my project, buff size is varying.
I suggest you at minimum should stop using MFC for collections (CByteArray even have a vfptr!), and start using a custom allocator.
In this case, which is my best solution (Using CArray or not)?
Not.
To be completely honest I'd say using any MFC collection class is almost always the wrong thing, but that's a completely different discussion.
|
|
|
|
|