| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2278 人关注过本帖
标题:高手把我下面VB转一下DELPHI代码
只看楼主 加入收藏
rogersgb
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2016-2-3
结帖率:47.37%
收藏
已结贴  问题点数:20 回复次数:1 
高手把我下面VB转一下DELPHI代码
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
'获取IP地址
Private Const MAX_IP = 255
Private Type IPINFO
            dwAddr   As Long    'IP地址
            dwIndex   As Long
            dwMask   As Long    '掩码
            dwBCastAddr   As Long    '广播地址
            dwReasmSize   As Long
            unused1   As Integer
            unused2   As Integer
End Type
Private Type MIB_IPADDRTABLE
            dEntrys   As Long
            mIPInfo(MAX_IP)   As IPINFO
End Type
Private Type IP_Array
            mBuffer   As MIB_IPADDRTABLE
            BufferLen   As Long
End Type
Dim strIP     As String
Private Function ConvertAddressToString(longAddr As Long) As String
    Dim myByte(3)     As Byte
    Dim Cnt     As Long
    CopyMemory myByte(0), longAddr, 4
    For Cnt = 0 To 3
        ConvertAddressToString = ConvertAddressToString + CStr(myByte(Cnt)) + "."
    Next Cnt
    ConvertAddressToString = left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
End Function
Public Sub Start()
    Dim Ret     As Long, Tel       As Long
    Dim bBytes()     As Byte
    Dim Listing     As MIB_IPADDRTABLE
    On Error GoTo END1
    GetIpAddrTable ByVal 0&, Ret, True
    If Ret <= 0 Then Exit Sub
    ReDim bBytes(0 To Ret - 1) As Byte
    GetIpAddrTable bBytes(0), Ret, False
    CopyMemory Listing.dEntrys, bBytes(0), 4
    For Tel = 0 To Listing.dEntrys - 1
 CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(Tel))
If InStr(1, ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr), "10.26") > 0 Or InStr(1, ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr), "10.6") > 0 Or InStr(1, ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr), "10.86") > 0 Or InStr(1, ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr), "10.1") > 0 Or InStr(1, ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr), "10.21") > 0 Or InStr(1, ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr), "10.81") > 0 Then
 strIP = ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr)
 Shell "route -p add 100.0.0.0 mask 255.255.255.0 " & strIP, vbHide
        End If
    Next
    Exit Sub
END1:
    MsgBox "ERROR"
End Sub
搜索更多相关主题的帖子: Private Long End Dim InStr 
2017-10-09 17:08
wlrjgzs
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:26
帖 子:212
专家分:1566
注 册:2017-4-10
收藏
得分:20 
免费的话,估计没有人愿意给你搞。把一种语言转换成另一种语言,比编写一个程序麻烦多了。
2017-10-09 19:30
快速回复:高手把我下面VB转一下DELPHI代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.066670 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved