应用程序未运行而不检查系统IP地址 [英] Application not run without check System IP Address

查看:83
本文介绍了应用程序未运行而不检查系统IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我有一个Windows桌面应用程序。而且我想知道我将如何检查此PC系统IP是否等于此IP。然后
我的应用程序运行。否则它必须显示消息。

推荐答案

这是一个函数

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


这篇关于应用程序未运行而不检查系统IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆