Results 1 to 12 of 12

Thread: Please Help: Detecting the Internet from a simple Function...

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Please Help: Detecting the Internet from a simple Function...

    Hello, I am trying to write a net detecting function, that is able to work with Visual Basic and then make a set of CommandButtons, be either .Enabled = True or either False, depending on the state of the Internet function process, is either True or False. It has taken me all night to get this far and then I was trying it alone, and then came to my senses and then got help from the Forum, instead. I wasn't able to come up with anything, I also don't want an extra ActiveX Control Object to go along with the ride to the detection. Because I have been looking on the Internet and then found that neither one of them, had any kind of Control to be loaded into the process. That part I like about it, because I don't want to source code, a lot of code, being like my special idea that I must be able to have a program that is really small and then that is also very efficent in what it does...

    !! Thanks in advance !!
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  2. #2
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Re: Please Help: Detecting the Internet from a simple Function...

    Right well, I am still not there. But then the matter still stands. I have found the source code to do the work, but then there is stil the fact of the matter that the source code uses the Internet Transfer Control, but still is very slow at processing the information even when the Timer is setup at an .Interval of one, yes that is correct one millisecond and the events are still lagging behind the computer, even with anything that I try to work with the processes that I have been able to find on the Internet's Tutorials. For the fact that still stands, it looks like I am going to need to use a Control and then it also looks like it's going to be the Internet Transfer Control, because it works. But then not all of the time and it's very slow at processing, as stated above in this Post. Also I am working to pull this source code and project into a ActiveX Control Object and then take it to a VBA Application, which is called: Adobe Director MX version 11.5 for Windows...
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  3. #3
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,844

    Re: Please Help: Detecting the Internet from a simple Function...

    this always work for me

    Code:
    Option Explicit
    
     Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer
    
     Private Sub Command1_Click()
      Command1.Enabled = CBool(InternetGetConnectedState(0, 0))
      Command1.Caption = "Internet: " & CBool(Command1.Enabled)
     End Sub

  4. #4
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Re: Please Help: Detecting the Internet from a simple Function...

    !! Cool, hey thanks for the Input$ !!
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  5. #5
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Re: Please Help: Detecting the Internet from a simple Function...

    I have been able to test your source code and then it turns on right, but then it does turn off right, about like I want it to do. Can you tell me how to get it to activate using a Timer. I was using a Timer's .Interval of about a one millisecond, just to be sure on the amount of time that it needed to fire up and then exectute just right. I didn't, so then I am going to post my source code, for you to have a good look at, if that would be alright with you, that is???
    Code:
    Option Explicit
    '
    Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer
    '
    Private Sub Timer1_Timer()
        cmd_VDir1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Word1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Spread1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_dBase1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Web1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Audio1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Desktop1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Movie1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Settings1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_New1.Enabled = CBool(InternetGetConnectedState(0, 0))
        cmd_Open1.Enabled = CBool(InternetGetConnectedState(0, 0))
    End Sub
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  6. #6
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,844

    Re: Please Help: Detecting the Internet from a simple Function...

    Put timer interval to at least 3000 You shouldnt have a problem and maybe instead of executing the api 10 times put a boolean variable with the api true or falseq

  7. #7
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Re: Please Help: Detecting the Internet from a simple Function...

    Put timer interval to at least 3000 You shouldnt have a problem and maybe instead of executing the api 10 times put a boolean variable with the api true or falseq
    Can you please show me, how to do so. I know that it is, something like a Property that must be setup. But then I only know to do that for an ActiveX Control Object, and not a handler...
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  8. #8
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,532

    Re: Please Help: Detecting the Internet from a simple Function...

    InternetGetConnectedState
    while the function is name is appropriate, it is misleading, it will detect the state of your lan, so if you are connected to a router, but your internet connection is down, it lies, test for your self
    Last edited by westconn1; Aug 16th, 2012 at 05:06 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,844

    Re: Please Help: Detecting the Internet from a simple Function...

    @westconn - I havent tested that far maybe try with this api

    Code:
    Option Explicit
    Private Declare Function InternetCheckConnection _
             Lib "wininet.dll" Alias "InternetCheckConnectionA" ( _
             ByVal lpszUrl As String, _
             ByVal dwFlags As Long, _
             ByVal dwReserved As Long) As Long
    
    Private Const FLAG_ICC_FORCE_CONNECTION = &H1
    
    Private Sub Command1_Click()
    MsgBox CBool(InternetCheckConnection("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0&))
    End Sub
    Last edited by Max187Boucher; Aug 16th, 2012 at 05:19 PM.

  10. #10
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Re: Please Help: Detecting the Internet from a simple Function...

    But the one that I am currently using from before, works. But then I must then be able to call it when the state of the IP changes, totally. For example if the computer's user logs off then it should change state. Cause it works, just fine before when the computer starts up. But then it must be able to change state, after and then during the operation of the machine...
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  11. #11
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,844

    Re: Please Help: Detecting the Internet from a simple Function...

    i'm not sure what you are looking for... but it is very simple what i think you are trying to do

    Code:
    Private Declare Function InternetCheckConnection _
             Lib "wininet.dll" Alias "InternetCheckConnectionA" ( _
             ByVal lpszUrl As String, _
             ByVal dwFlags As Long, _
             ByVal dwReserved As Long) As Long
    
    Private Const FLAG_ICC_FORCE_CONNECTION = &H1
    
    
    Private Sub Command1_Click()
    Dim IE As Object
    
    Set IE = CreateObject("InternetExplorer.Application")
      IE.navigate "www.google.com"
      IE.Visible = True
    End Sub
    
    Private Sub Form_Load()
    Command1.Caption = "Google"
    Command1.Enabled = False
    Timer1.Interval = 1000 'I put 1000 ms (1 sec).. do not put 1 ms it will execute way too many times
    Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
    Command1.Enabled = CBool(InternetCheckConnection("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0&))
      
    'unquote below if needed... this will put all command buttons enabled or not
    
    'Dim Objects As Object
    'Dim Connected As Boolean
    
    'Connected = CBool(InternetCheckConnection("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0&))
    
    'For Each Objects In Me
      'If TypeOf Objects Is CommandButton Then
        'Objects.Enabled = Connected
      'End If
    'Next
    End Sub
    you need at least 1 commandbutton "Command1" and only 1 timer "Timer1"

    Edit: Is in red
    Last edited by Max187Boucher; Aug 16th, 2012 at 07:13 PM.

  12. #12
    PowerPoster
    Join Date
    Dec 07
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,075

    Re: Please Help: Detecting the Internet from a simple Function...

    Well then I have been able to make this Thread Resolved, so then thanks for the help guys, because that helped me alot in return I am going to make an added rep, to one of you!!
    I have a huge free products range, of computer software in which you can download using any kind of 32-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
    Main Page: Click Here | Blog Page: Click Here | Products Page: Click Here | News Page: Click Here | Horoscopes Page: Click Here | CodeBank Page: Coming Really Soon...

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •