首页 /编程语言和算法/VB6/VBA/ASP
 VB6 判断是否是Windows的可执行文件
2023年5月5日 14:04

新建From1(窗体),新建Command1(按钮CommandButton),代码:

Private Function f_WinExe(ByVal Exe As String) As Integer
    Dim fh As Integer
    Dim t As String * 1

    fh = FreeFile
    Open Exe For Binary As #fh
        Get fh, 25, t
    Close #fh

    f_WinExe = (Asc(t) = &H40&)
End Function

Private Sub Command1_Click()
    Dim strFN As String
    
    strFN = App.Path & "\manongku.exe" '如果是exe文件显示-1
    MsgBox f_WinExe(strFN)
    
    strFN = App.Path & "\manongku.txt" '如果是不是exe文件显示0
    MsgBox f_WinExe(strFN)    
End Sub


 
全部回复(0)
首页 | 电脑版 |