Interesting Internet control problem

elminsters
01-06-2005, 02:21 PM
Hi everyone, this is my first time posting but ive read lots of great tips/info on the forum... keep up the good work.
Ive had quite alot of experience with VB 6 and just recently moved over to .NET, ive got a reasonable amount of experience with OOP though.
The basics of the program that im trying to design... 1) sets the proxy information 2) Gotos a website, which redircts 3) checks weather the second website is even partially loaded 4) closes the link 5) goes onto the next proxy.

It redirects via a <META HTTP-EQUIV="refresh" content="0;URL=SOMELINK"> Tag.
Ive managed to get this working in Vb 6, using Internet explorer, Changing the proxy settings via registry, and closeing the webpage via mouse click (i know its the wrong way, but the Api to close the window didnt close it while its busy). :confused:

In VB .NET i made it do exactly that, (manually extracted the link from the redirecting page by cropping the Html code and modifying it) although it didnt register it correctly, even though i also changed the referer to the redirecting page.

I tried to do it with the following..
Public WithEvents Explorer As SHDocVw.InternetExplorer

'[Change registry settings here]
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(LinkToUse)

Private Sub Explorer_NavigateComplete2(ByVal pDisp As Object, ByRef URL As Object) Handles Explorer.NavigateComplete2
'[Check if the link is where i wanted it to go]
Explorer.quit()
'[Restart the process]

Although... the Quit kinda screws it because it doesnt allow it to reassign it to the new internet explorer. :(

Anyone know(in order of importance):
1) some basic code to do that would do loop i described? (Most important)
2) A better way to change the proxy settings?
3) Any other way or improving it?

Any comments are welcome, and thanks in advance for any useful information :D :D

elminsters
01-07-2005, 06:48 AM
So far the only way ive found to do it (That works 100% of the time) is like this with 2 timers: (I know its really bad coding, i done it quickly and it was only recently transfered from VB6 to VB.NET :( )

Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
On Error GoTo ErrorHandler
If ProxyList.Items.Count <= Current Then
Call Start_Click(Start, New System.EventArgs) 'Stops all process
Exit Sub
End If

If isFirstTime Then Current -= 1 'Checks if its first then makes adjustment so it points at 0 in Proxy listbox array
Current += 1 'Counter at start so other processes will be on the same count

RegEntry4 = Chr(34) & "ProxyServer" & Chr(34) & " = " & Chr(34) & ProxyList.Items.Item(Current) & Chr(34) 'Edit Registry value to current proxy

FileOpen(1, "C:/Proxy.reg", OpenMode.Output) 'open proxy.reg file
PrintLine(1, RegEntry1)
PrintLine(1, "")
PrintLine(1, RegEntry2) 'Construct proxy.reg file with new information
PrintLine(1, RegEntry3)
PrintLine(1, RegEntry4)
FileClose(1)

Shell(RegeditExe) 'Insert proxy.reg into registry

Dim CurPoint As Point
CurPoint = Cursor.Position() 'get current position
Cursor.Position = New Point(MouseX, MouseY) '}
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)'} Close currently opened window via mouse click
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) '}
Cursor.Position = CurPoint 'restore mouse point

Shell(FullShell, AppWinStyle.MaximizedFocus) 'Load new window with link

isFirstTime = False
Exit Sub
ErrorHandler:
MsgBox(Err.Description)
End Sub
I really dont like the double quotation marks it sometimes confuses me, hence the Chr(34).

Private Sub Timer2_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer2.Tick
If Current <> LastAdded Then
hWindow = FindWindow(vbNullString, "LINK I WANT TO GOTO - Microsoft Internet Explorer")
If IsWindow(hWindow) = 1 Then
Then
NewProxyList.Items.Add(ProxyList.Items.Item(Current))
LastAdded = Current
Timer1.Stop()
Timer1.Start()
NewTotal.Text += 1
End If
hWindow = FindWindow(vbNullString, "Cannot find server - Microsoft Internet Explorer")
If IsWindow(hWindow) = 1 Then
Timer1.Stop()
Timer1.Start()
End If
End If
End Sub

A number of problems with it:

-It doesnt pickup any other server errors other than if it cant connect (like proxy authentication errors, 404's, etc etc)
-Its a stupid way to change proxy, there has to be an easier option
-I dont know why, but i cant change the proxy settings for a single dialup connection, rather than just a Lan connection. There must be a way to do that as well.

Ill go look up a better way of closeing the program, since the last Api call i tried didnt close it when it was busy... :confused:

elminsters
01-08-2005, 10:07 AM
For some reason now, when i run it on a different PC with windows XP, it comes up with something like:
Application terminated
0xc0000135 error failed to load something or something... :confused:

I looked up the c0000135 error and it turns out to be a missing DLL. Although ive changed all the compile functions to "Release" mode, and reduced all the references down to a minimum. Yet it still doesnt load. I would have thought its something to do with the program not including the DLL's in the build...

Then again... i sent it to a friend, and he could run it without any extra DLL's. :confused:

Im real confused...

Edit:
-Why cant you edit it more than once?
-Ive found a suitable rutine to close the internet explorers.

-Any suggestions on:
---The 0000135 error
---How to check if the IE open has loaded and/or had an error loading

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum