Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

DestroyWindow and API calls

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
frangers99
Asked:
frangers99
1 Solution
 
ITugayCommented:
listening....
0
 
frangers99Author Commented:
Adjusted points to 150
0
 
frangers99Author Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
frangers99Author Commented:
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
 
brunoheCommented:
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
 
frangers99Author Commented:
Adjusted points to 170
0
 
frangers99Author Commented:
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
 
craig_capelCommented:
//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
 
craig_capelCommented:
right, ignore that..... :)

0
 
craig_capelCommented:
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
 
frangers99Author Commented:
thanks once again, when i finish the program i'll send it to you if you want, just write back.
0
 
craig_capelCommented:
ah thanks... what is it your creating?....
0
 
craig_capelCommented:
ignore that comment too, did not thinking of goint to the top of the screen :)
0
 
craig_capelCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now