Solved

DestroyWindow and API calls

Posted on 2000-03-10
14
297 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
Comment Utility
listening....
0
 

Author Comment

by:frangers99
Comment Utility
Adjusted points to 150
0
 

Author Comment

by:frangers99
Comment Utility
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
 

Author Comment

by:frangers99
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points to 170
0
 

Author Comment

by:frangers99
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:craig_capel
Comment Utility
//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
Comment Utility
right, ignore that..... :)

0
 
LVL 2

Accepted Solution

by:
craig_capel earned 180 total points
Comment Utility
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
Comment Utility
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
Comment Utility
ah thanks... what is it your creating?....
0
 
LVL 2

Expert Comment

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

Expert Comment

by:craig_capel
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now