Solved

DestroyWindow and API calls

Posted on 2000-03-10
14
303 Views
Last Modified: 2010-04-04
I am trying to create a small program that blocks the windows NT messages
that people can send(the net send command is used as a bombing tool at our
school as well). As a first step i intend to block all messages but further
implement the ability to block individual computers.
Here's the present catch... When a 'Messenger Service' window pops up it
isn't a process. hence, i can't use the TerminateProcess command...i have
used the closewindow call, but this only minimizes the window, not closes
it all together. I have tried the 'destroywindow' command but it doesn't
appear to work. I tried 'destroywindow' on a normal window as well that
does have a PID yet it still didn't work.
So, what command do i call to close a window completely that doesn't have a
PID?

Also, if possible, what command do i call to search inside this window for
a ceratin piece of text (ie. a computer name) so i can block the message?
0
Comment
Question by:frangers99
14 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2603756
listening....
0
 

Author Comment

by:frangers99
ID: 2603768
Adjusted points to 150
0
 

Author Comment

by:frangers99
ID: 2603775
Do you know how i do it? it's just really tricky because windows NT messenger service is not a process so it's hard to close entirely (although, close window works)
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:frangers99
ID: 2603778
Do you know how i do it? it's just really tricky because windows NT messenger service is not a process so it's hard to close entirely (although, close window works)
0
 

Expert Comment

by:brunohe
ID: 2603820
Why don't you deny access do Windows/system32 directory? It shouldn't be a problem 'cause you're using NT.

This would be much easier.
0
 

Author Comment

by:frangers99
ID: 2603840
Adjusted points to 170
0
 

Author Comment

by:frangers99
ID: 2603849
It would make sense, but i am doing it more a a tool for students who are getting bombed or wish to choose who NOT to get messages from, the reason i need to get a function like DestroyWindow working is so then a user can type in a computer name to block and since that when a user sends a message their computer name appears on the message, it should be easily blockable.

At present when i use destroy window it doesn't work and i get error 216.
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2604185
//destroywindow
                   //sendmessage(form1.handle,wm_destroy,0,0);
                   sendmessage(form1.handle,wm_close,0,0);


                   Intresting.... I invoked destroy window like this, and watch the icon in the top left corner as you
                   use wm_destroy....

                   You can use Sendmessage to close the window or you can do this....

                   var
                   wnd2 : hwnd;
                   ProcessID,cpid : Cardinal;
                   begin
                   wnd2:=findwindow('Shell_TrayWnd',nil); //handle of window

                   ProcessID := GetWindowThreadProcessID(wnd2,@cpid);
                   TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,cpid),1);
                   end;


there ya go :)
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2604194
right, ignore that..... :)

0
 
LVL 2

Accepted Solution

by:
craig_capel earned 180 total points
ID: 2604236
the second part is easy, i am working on that as well, this may give you some clues as what to do...

http://members.xoom.com/craig_c/mouse.zip   this WILL NOT work under NT, simply because i am accessing ports with it, in al,60h the keyboard port... thats in the timer section, there may be some thing you notice that you like...

ok this is what you need to do... get the handle of the window running, then... if you have winsight? (comes with delphi) then depending on the order you need to do things like

h:=windowshandle;
h:=getwindow(h,gw_child);
 h:=getnextwindow(h,gw_hwndnext);
h:=getwindow(h, GW_HWNDPREV);
h:=getwindow(h,GW_HWNDLAST);

Just put them in a loop, calling each child window, until you hit a windows that does not exist, backup and continue, by using gw_child, Winsight is a big help when doing this, so in the end you always get to the same text window....

once you have the window, you will need to get the text out... this here wil do that

var i1 : integer;
s1 : string;
 begin
  i1 := SendMessage(WinHandle, WM_GETTEXTLENGTH, 0, 0);
  SetLength(s1, i1 + 1);
  SetLength(s1, SendMessage(WinHandle, WM_GETTEXT, i1 + 1,integer(s1)));
  memo1.text := s1;
end;

var wnd:hwnd;
                          URL:string;
                      begin
                      wnd:=findwindow('CabinetWClass',nil);
                      wnd:=findwindowex(wnd,0,'Worker',nil);
                      wnd:=findwindowex(wnd,0,'ReBarWindow32',nil);
                      wnd:=findwindowex(wnd,0,'ComboBoxEx32',nil);
                      wnd:=findwindowex(wnd,0,'ComboBox',nil);
                      wnd:=findwindowex(wnd,0,'Edit',nil);

                      if wnd<>0 then
                      begin
                        URL:='http://www.xxxx.com';
                        sendmessage(wnd, WM_SETTEXT, length(URL),longint(pchar(URL)));
                      end;


and thats an example of another way, hope you figure this out :)

Craig C.
0
 

Author Comment

by:frangers99
ID: 2610451
thanks once again, when i finish the program i'll send it to you if you want, just write back.
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2610511
ah thanks... what is it your creating?....
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2610512
ignore that comment too, did not thinking of goint to the top of the screen :)
0
 
LVL 2

Expert Comment

by:craig_capel
ID: 2610577
god..... its 01:41am, is really tired and can not think straight....... sorry for the bad comments :) been up 2 days solid.

Craig C.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question