Link to home
Start Free TrialLog in
Avatar of KingSencat
KingSencat

asked on

Connecting to a website without any browser!

Hello experts!

I am newbie at VB6.0 and i would like to ask if is possible to help me out ... i want to connect to a website without any browser .. i mean hidden .. i have already compile a vb application and i have created a button , when i click the button i want to connect to a website but hidden,without any browser or whatever :) ... did somebody have this source ?
Avatar of Computron
Computron

What do you want to do when you connect to this website ?
If you just want to download a page try this

go to project, components and check "Microsoft Internet Transfer Control"
now drop the inet1 control on your form
put a multiline textbox on your form
in your buttons click event put in Call GrabPage

Public Sub GrabPage()

        Dim strData as String

        Inet1.Cancel
        Inet1.url = "http://www.google.com"
        strData = Inet1.OpenURL(, icString)
        While Inet1.StillExecuting = True
            DoEvents
        Wend
        textbox1.text = strData

End Sub

This will grab googles page and stick the source into your textbox
Avatar of KingSencat

ASKER

I want when i am clicking the Button at the application , to connecting to a website ( ONLY ) but dont showing in the screen any browser .. hidden ...
Everything a webbrowser does is the following:

It connects to the server.
When connection is complete it sends a request for a webpage:
Winsock1.SendData "GET / HTTP/1.1" & vbCrLf & vbCrLf
And the webserver returns with the index.html page


Is this what you are looking for?

Atan Asfaloth

Most webservers are designed to drop you unless you are requesting pages. After connecting, what do you want to accomplish ? The code I gave will connect you and download the URLs source page.
You could use a Webbrowser control with visibility property set to hidden, or you could use the Winsock Control as in the example above. To add these to your project, Choose Project --> Components and select the 'Microsoft Winsock Control' (for winsock)or the 'Microsoft Internet Controls' (for webbrowser)

Atan Asfaloth
Guys ... I just want when i click the button to just visiting the website ... this website log's ip addresss ... that all i ineed , when somebody click in the application the button to connect hidden to the website , no downloads no nothing just connecting to the website hidden without any browser , invisible .
I think u wish to download some updates to ur project!
Am i right?
No ... i just want when i click the button to connecting to a website .. but invisible from me ... without any browser or something .. nothing to appear at my screen .. just connecting to a site for 10 seconds and then exit
ASKER CERTIFIED SOLUTION
Avatar of AtanAsfaloth
AtanAsfaloth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, this will all be invisible, during runtime the Winsock Control will not be shown :)
Thank you Atan ... i will check it later coz i dont have VB at this pc .. i hope is work .. , also its possibe to tell me how i will make this application to start at startup ?
Also if is possible to do this application to work without any button ... when i click for 1st time to register a key for the startup and then to connecting hidden to the website ... all invisible :)) , can you help me out ?
To run the application at startup you can place a hyperlink in the Startup folder in your Start menu or you can edit the registry and add a key to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run (for example through Start --> Run --> regedit)

Thanks for the points, but I reccommend that you test solutions before accepting them :)
I did'nt test this solution and I just found a typo... The writer of the code can often easily find typo's while you can have a hard time finding ithem :)

Use the following code instead of the last part:





Private Sub Command1_Click()
    'This is your button code that connects to the webpage
    Winsock1.Close
    Winsock1.Connect "http://www.yourwebpage.com", 80
End Sub

Private Sub Winsock1_Connect()
    'The control is now connected, request the webpage
    Winsock1.SendData "GET /yourpage.php HTTP/1.1" & vbCrLf & vbCrLf
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    'This sub will be called when the server is sending data
    'Declare Vars
    Dim strData As String
    '
    'Retrieve the data
    Winsock1.GetData strData
    '
    'And just for you: output the data, this will show you the HTML code of the page
    'You can remove this
    Debug.Print strData
End Sub






Good luck with your project!

Atan Asfaloth
I dont like to do the registry manually , you have any source that its do it automatic when i open the application ?
Hmm, although completely off the topic of this qeustion

I think your answer can be found here:

https://www.experts-exchange.com/questions/21398550/How-to-put-a-VB6-program-on-Startup.html
Atan i get this error:
 
Run time Error: ' 424 '

Object Required..
Are you sure you've added the Winsock Control?

Like

1) Add Winsock Control:
Choose Project --> Components and select 'Microsoft Winsock Control'
2) In your component tab, a new control will be added: The Winsock Control
3) Drag this to you form, on your form you should see a square containing two 'connected' computers

If you see this square, click it and make sure the name property value is "Winsock1"
Also, click on your button and make sure the name property value is "Command1"




OK, I tested the following code and that worked for me:




'The Website you wish to connect to:
Const strDomain As String = "yourdomain.com"
Const strURL As String = "yourFolder/yourfile.html"

Private Sub Command1_Click()
    'This is your button code that connects to the webpage
    Winsock1.Close
    Winsock1.Connect strDomain, 80
End Sub

Private Sub Winsock1_Connect()
    'The control is now connected, request the webpage
    Winsock1.SendData "GET /" & strURL & " HTTP/1.0" & vbCrLf & vbCrLf
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    'This sub will be called when the server is sending data
    'Declare Vars
    Dim strData As String
    '
    'Retrieve the data
    Winsock1.GetData strData
    '
    'And just for you: output the data, this will show you the HTML code of the page
    'You can remove this
    Debug.Print strData
End Sub
Its work with no errors but is not connecting to the website
That is weird...

Do you have a firewall restricting access to the internet for this app?
Then again you would see errors I guess,

Can you add the line

Debug.Print "No Errors here"

To various places in the code to see where it goes wrong, starting in the Command1_Click Sub and from there to the Winsock1_Connect sub and the Winsock1_DataArrival sub?

Check when you see this text in your debugging window and when you do not...

Atan Asfaloth
Const strDomain As String = "http://samplesite.com/"
Const strURL As String = "sample.php"


Private Sub Command1_Click()
    'This is your button code that connects to the webpage
    Winsock1.Close
    Winsock1.Connect strDomain, 80
End Sub
Private Sub Winsock1_Connect()
    'The control is now connected, request the webpage
    Winsock1.SendData "GET /" & strURL & " HTTP/1.0" & vbCrLf & vbCrLf
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    'This sub will be called when the server is sending data
    'Declare Vars
    Dim strData As String
    '
    'Retrieve the data
    Winsock1.GetData strData
    '
    'And just for you: output the data, this will show you the HTML code of the page
    'You can remove this
    Debug.Print strData
End Sub


This is all the source .. i have add the winsock control ... i run the application i click at command1 and still not connecting to the site .. i have disable also firewall
Is your button called Command1?

Add a breakpoint to the line 'Private Sub Command1_Click' (click on the line and press F9)

If you now run the program and click the button, does the editor take you to the Command1_Click sub?

o, And:

Remove the leading http:// andthe trailing slash:

Const strDomain As String = "http://samplesite.com/"

should be

Const strDomain As String = "samplesite.com"
I make it and still not connecting to the site
i think is the port ... : because the icons from network connection from the sys tray are lighting
also maybe is the winsock properties
port 80 is standard for html connection. A normal webbrowser would connect to this port, and this program will imitate an internet connection

try the example with



Const strDomain As String = "experts-exchange.com"
Const strURL As String = ""
Do you see anything at all in your immediate window?
its not .html connection ... its .php connection
It doesn't matter, it is a webserver and that is what counts. HTTP connections go through port 80 so that is the port you want to use...
but why is not working ? :((
can you make the full project and send it to me ? please i really need it
OK

Start from scratch:

Create a NEW PROJECT

Add a button to your form, don't change any of it's properties
Add winsock control to your form, don't change any of it's properties

Go to the form's code window and make sure this is the only code present:







Const strDomain As String = "experts-exchange.com"
Const strURL As String = ""

Private Sub Command1_Click()
    Debug.Print "Button was pressed"
    'This is your button code that connects to the webpage
    Winsock1.Close
    Winsock1.Connect strDomain, 80
End Sub

Private Sub Winsock1_Close()
    Debug.Print "Winsock is closed"
End Sub

Private Sub Winsock1_Connect()
    Debug.Print "Winsock is connecting"
    'The control is now connected, request the webpage
    Winsock1.SendData "GET /" & strURL & " HTTP/1.0" & vbCrLf & vbCrLf
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Debug.Print "Winsock is receiving data"
    'This sub will be called when the server is sending data
    'Declare Vars
    Dim strData As String
    '
    'Retrieve the data
    Winsock1.GetData strData
    '
    'And just for you: output the data, this will show you the HTML code of the page
    'You can remove this
    Debug.Print strData
End Sub

Private Sub Winsock1_SendComplete()
    Debug.Print "Winsock has sent data"
End Sub





Run the project and post  the entire contents of the immediate window here
OS/2 Net.<br />
         </span>
<span style="padding-left: 10px;">
         Unix Net.<br />
         </span>
<span style="padding-left: 10px;">
         Win95 Ne
Winsock is receiving data
t.<br />
         </span>
<span style="padding-left: 10px;">
         WinNT Net.<br />
         </span>
<span style="padding-left: 10px;">
         Email/GroupWare<br />
         </span>
<span style="padding-left: 10px;">
         Broadband<br />
         </span>
<span style="padding-left: 10px;">
         Microsoft Network<br />
         </span>
<span style="padding-left: 10px;">
         VoIP/Voice over IP<br />
         </span>
<span style="padding-left: 10px;">
         Video Conferencing<br />
         </span>
<span style="padding-left: 10px;">
         Citrix<br />
         </span>
<span style="padding-left: 10px;">
         Sharepoint<br />
         </span>
</td>
</tr>
  <tr>
<td  class="item" style="border: 1px solid #FFFFFF; padding: 2px 2px 2px 2px; white-space: nowrap;">
      <img src="/mW.gif" class=markerWide><img src="/b.gif" width=1 height=1 class=inline>
<a href="/allTopics.jsp?t=34#prodappgen"><b>Applications:</b></a><br />
<span style="padding-left: 10px;">
         Mac Apps<br />
         </span>
<span style="padding-left: 10px;">
         MS Office<br />
         </span>
<span style="padding-left: 10px;">
         OS/2 Apps<br />
         </span>
<span style="padding-left: 10px;">
         Viruses<br />
         </span>
<span style="padding-left: 10px;">
         SAP<br />
         </span>
<span style="padding-left: 10px;">
         Lotus Smart Suite<br />
         </span>
<span style="padding-left: 10px;">
       
Winsock is receiving data
 Email<br />
         </span>
<span style="padding-left: 10px;">
         Graphics<br />
         </span>
<span style="padding-left: 10px;">
         WordPerfect Office Suite<br />
         </span>
<span style="padding-left: 10px;">
         MultiMedia Applications<br />
         </span>
<span style="padding-left: 10px;">
         Productivity Applications<br />
         </span>
<span style="padding-left: 10px;">
         EAI<br />
         </span>
<span style="padding-left: 10px;">
         Microsoft Project<br />
         </span>
<span style="padding-left: 10px;">
         CAD<br />
         </span>
<span style="padding-left: 10px;">
         CRM<br />
         </span>
<span style="padding-left: 10px;">
         Groupwise<br />
         </span>
<span style="padding-left: 10px;">
         ERP<br />
         </span>
</td>
<td  class="item" style="border: 1px solid #FFFFFF; padding: 2px 2px 2px 2px; white-space: nowrap;">
      <img src="/mW.gif" class=markerWide><img src="/b.gif" width=1 height=1 class=inline>
<a href="/allTopics.jsp?t=343#miscellaneous"><b>Miscellaneous:</b></a><br />
<span style="padding-left: 10px;">
         Lounge<br />
         </span>
<span style="padding-left: 10px;">
         Puzzles &amp; Riddles<br />
         </span>
<span style="padding-left: 10px;">
         Philosophy &amp; Religion<br />
         </span>
<span style="padding-left: 10px;">
         Math &amp; Science<br />
         </span>
<span style="pa
Winsock is receiving data
dding-left: 10px;">
         URLs<br />
         </span>
<span style="padding-left: 10px;">
         New Net Users<br />
         </span>
<span style="padding-left: 10px;">
         Games<br />
         </span>
</td>
<td  class="item" style="border: 1px solid #FFFFFF; padding: 2px 2px 2px 2px; white-space: nowrap;">
      <img src="/mW.gif" class=markerWide><img src="/b.gif" width=1 height=1 class=inline>
<a href="/allTopics.jsp?t=180#commspt"><b>Community Support:</b></a><br />
<span style="padding-left: 10px;">
         EE Bugs<br />
         </span>
<span style="padding-left: 10px;">
         Expert Input<br />
         </span>
<span style="padding-left: 10px;">
         New Topics<br />
         </span>
<span style="padding-left: 10px;">
         Suggestions<br />
         </span>
<span style="padding-left: 10px;">
         New to EE?<br />
         </span>
<span style="padding-left: 10px;">
         CleanUp<br />
         </span>
<span style="padding-left: 10px;">
         Feedback<br />
         </span>
<span style="padding-left: 10px;">
         ExpertCare<br />
         </span>
</td>
</tr>
</table>
</td><td class=bRR></td></tr><tr><td class=bBl></td><td class=bB></td><td class=bBr><img src="/b.gif" width=10 height=10></td></tr></table>
</td>
        </tr>
        <tr>
          <td>
            <table class="fullWidth">
              <tr>

                <td class="logoBottom">
                  <a href="/"><img src="/b.gif" al
Winsock is receiving data
t="Copyright &copy; Experts Exchange LLC 2006. All rights reserved." width=263 height=41px class="inline" /></a>
                </td>
                <td class="bgBottom">
                  <table>
  <tr>
    <td>
      <a href="https://www.experts-exchange.com/aboutUs.jsp" title="Contact Us">Contact Us</a>
      | <a href="https://www.experts-exchange.com/memberAgreement.jsp" title="Member Agreement">Member Agreement</a>
      | <a href="http://www.alexa.com/data/details/main?q=experts-exchange.com&url=http://www.experts-exchange.com/" title="Internet Rank" onclick="void(window.open(this.href,'','')); return false;">Internet Rank</a>
      | <a href="https://www.experts-exchange.com/privacyPolicy.jsp" title="Privacy Policy">Privacy Policy</a>
      | <a href="https://www.experts-exchange.com/supporters.jsp" title="Supporters">Supporters</a>
      | <a href="https://www.experts-exchange.com/siteMap.jsp" title="Site Map">Site Map</a>
    </td>
  </tr>
  <tr>
    <td align=center>
      Copyright &copy; Experts Exchange LLC 2006. All rights reserved.
    </td>
  </tr>
</table>
</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

</body>
</html>


  <!-- www8.experts-exchange.com:80 -->

Winsock is closed
This is the source code of the web page,
This is exactly what this program is designed to do...
thanks a lot is working