vb.net检测远程登录 [英] vb.net detect remote log in

查看:95
本文介绍了vb.net检测远程登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里...
用户使用 登录物理或使用 登录时可以检测到的代码是什么?远程光盘顶部",团队查看器",远程管理" ,"VNC","Hamachi"或其他Sw .
我的vb是2008 \ 3.5

hi there ...
what the code that can Detect if the user log in physically or he log in using "remote disc-top","team viewer","remote administration","VNC","Hamachi" or other Sw.
my vb is 2008\3.5

推荐答案

尝试以下代码:
Try this code :
Imports System.Management
Imports System.DirectoryServices
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Module Module1
    Dim objManagementClass As ManagementClass
    Dim objManagementScope As ManagementScope
    Dim objManagementBaseObject As ManagementBaseObject
    Public Strcomputer As String = ""
    Sub Main()
        Dim WMIScope As Management.ManagementScope
        Dim WMIConnectionOptions As New Management.ConnectionOptions
        Dim strRootDomain As String
        Dim objRootLDAP As DirectoryEntry
        Dim query As ManagementObjectSearcher
        Dim queryCollection As ManagementObjectCollection
        Dim oq As New System.Management.ObjectQuery
        Dim mo As New ManagementObject
        Dim UserDomain As String
        Dim UserID As String
        Dim StrLoggedUserSID() As Byte
        Try
            Dim Strcomputer As String = My.Application.CommandLineArgs.Item(0)
            With WMIConnectionOptions
                .Impersonation = System.Management.ImpersonationLevel.Impersonate
                .Authentication = System.Management.AuthenticationLevel.Packet
            End With
            WMIScope = New Management.ManagementScope("\\" & _
            Strcomputer & "\root\cimv2", WMIConnectionOptions)
            objRootLDAP = New DirectoryEntry("LDAP://RootDSE")
            strRootDomain = objRootLDAP.Properties.Item("rootDomainNamingContext").Value.ToString
            oq = New System.Management.ObjectQuery("SELECT UserName from Win32_ComputerSystem")
            query = New ManagementObjectSearcher(WMIScope, oq)
            queryCollection = query.Get()
            For Each oReturn As ManagementObject In queryCollection
                If Not oReturn("UserName") Is Nothing Then
                    Console.WriteLine(oReturn("UserName").ToString)
                Else
                    Console.WriteLine("Not logged in")
                End If
            Next
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        End Try
    End Sub


这篇关于vb.net检测远程登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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