none
Application not run without check System IP Address RRS feed

  • Question

  • My question is that i have a Windows Desktop Application. And i want how i will make a condition check that this PC System IP is equal to this IP. Then my Application runs. And otherwise it must show the message.
    Tuesday, January 1, 2019 9:46 AM

All replies

  • Here is a function

    Public Function GetLocalIPAddress() As String
        Dim host = Dns.GetHostEntry(Dns.GetHostName())
        For Each ip In host.AddressList
            If ip.AddressFamily = AddressFamily.InterNetwork Then
                Return ip.ToString()
            End If
        Next
        'Throw New Exception("No network adapters with an IPv4 address in the system!")
        Return ""
    End Function

    usage is hard coded but does not have to be

    If GetLocalIPAddress() = "10.0.0.12" Then
        ' run
    Else
        ' don't run - send a message via say MessageBox.Show and exit as you see fit
    End If


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites



    Tuesday, January 1, 2019 11:32 AM
    Moderator
  • Hi,

    Do you resolve the issue? If you resolve the issue,please mark the helpful as answer.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 4, 2019 2:29 AM
  • My question is that i have a Windows Desktop Application. And i want how i will make a condition check that this PC System IP is equal to this IP. Then my Application runs. And otherwise it must show the message.
    So your application cannot run on a PC that gets its LAN IP address from a router? I'd think that would cut your market by 80 % or more.
    Sunday, January 6, 2019 6:55 AM