Solved

DestroyWindow and API calls

Posted on 2000-03-10
14
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JAudiorecorder record freezing the app 29 92
Dynamically Created Query 3 81
Twebbrowser add css to the header 3 54
Microsoft Access 97 and Delphi XE2 9 85
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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