Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DestroyWindow and API calls

Posted on 2000-03-10
14
Medium Priority
?
320 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 720 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

718 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