![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
Hey yall, I decided to take my Download Blocker to vb.net from vb6. In vb6 I used a imer to look for the Download Windows every second, I tried that with .net and I couldnt get it to work. I dont know where a good place would be to put it in, It needs to look for the windows every second so everything is caught. I have tried Form1_Load,, Activate and Timer_Ticker, Disposed. I cant get any of them to work. Please give me a few ways I could do this or where I could put it. I once put it in Btnblock_Click and it found the window, So I know it is finding the window but I dont think the user wants to clikc that button everything something needs to be blocked. lol
But anyway I know its finding the window I juts need to put it in a place where it will be looking for it all the time. Thanks again yall
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,198
Rep Power: 5
![]() |
Why not place it in a separate thread? All the thread function needs to do is a continual loop that calls FindWindow(), closes the window if found, and sleeps for 1 second. Preferably, it would also check some flag so that, as your program exits, it could simply set that flag and the thread would terminate within 1 second.
As an aside, I'm not convinced that the best way to implement a "Download Blocker" is to simply close windows that are associated with a download. The workaround would be a little program that runs more frequently and sets the window label to something different --- or, even better, closing down your "Download Blocker". A better way would be to prevent programs from opening a network connection. Of course, that stops all email clients and browsers. |
|
|
|
|
|
#3 |
|
Professional Programmer
|
It's really not that big of deal as of now it's only used within my school. But thanks for the info and I'll look into it more.
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#4 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Realize that a clientside download blocker could be easily disabled.
A filtering transparent proxy would be more effective.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#5 |
|
Professional Programmer
|
Ok grumpy and I started what you said and here is the code I done for your idea and then the code for mine. Plus the outcome:
1. Your Idea Public Class Form1
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private IEDownload as Int32 = 0
Private Sub IEDownloads()
IEDownload = FindWindow("#32770", "File Download")
MsgBox(IEDownload.ToString + "Download Detected")
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim thrblock As New System.Threading.Thread(AddressOf IEDownloads)
thrblock.Start()
End Sub
End Class^^With that I get the message box as soon as I start the project, regardless if the download window is open or not. 2. My Code Public Class Form1
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private IEDownload As Int32 = 0
Private Sub IEDownloads()
IEDownload = FindWindow("#32770", "File Download")
MsgBox(IEDownload.ToString + "Download Detected")
End Sub
Private Sub Timer1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Disposed
Dim thrblock As New System.Threading.Thread(AddressOf IEDownloads)
thrblock.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim thrblock As New System.Threading.Thread(AddressOf IEDownloads)
thrblock.Start()
End Sub
End Class^^^ With that the msgbox doesnt appear till AFTER I close the download windows, well actually when I close the running project and I go back to design mode. I think I'm geting close, but much more of this shit, I'll goi back to vb6. lol No seriously thanks for yalls help thuis far, and hopefully I'm not that far off from fixing this problem. Also daemon thanks.
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#6 |
|
Professional Programmer
|
Well I found my problem. It was my message box. So I made a loop and and put it in a timer and it worked fine when I done form2.show lol. I dont know why but when I done the message boxes it'd just as soon as I loaded the form or w/e it would give a bunch of msg boxes. But I got it fixed now. Thanks for all yalls help
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|