星空网 > 软件开发 > ASP.net

VB.NET WinForm获取运行程序用户名

一个程序也许会被多个用户运行,如下:
VB.NET WinForm获取运行程序用户名


那在VB.NET的WinForm环境下,怎样获取User Name呢?
可从下面的方法:
VB.NET WinForm获取运行程序用户名


代码:

VB.NET WinForm获取运行程序用户名VB.NET WinForm获取运行程序用户名
Public Shared Function GetProcessOwner(ByVal ProcessName As String) As String      Dim po = String.Empty      Dim selectQuery As SelectQuery = New SelectQuery("Win32_Process")      Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(selectQuery)      Dim moc As ManagementObjectCollection = searcher.Get()      For Each proc As ManagementObject In moc        Dim s(1) As String        proc.InvokeMethod("GetOwner", CType(s, Object()))        If proc("Name").ToString() = ProcessName & ".exe" Then          po = s(1) & "\\" & s(0)        End If      Next      Return po    End Function

View Code

 




原标题:VB.NET WinForm获取运行程序用户名

关键词:.NET

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

敦煌网付款方式:https://www.goluckyvip.com/tag/30808.html
敦煌网广告:https://www.goluckyvip.com/tag/30809.html
危机仍未解除:https://www.goluckyvip.com/tag/3081.html
敦煌网国际站:https://www.goluckyvip.com/tag/30810.html
敦煌网海外仓:https://www.goluckyvip.com/tag/30811.html
敦煌网海外仓在哪:https://www.goluckyvip.com/tag/30812.html
如何从抖音上多挣钱?记住这12个字 :https://www.kjdsnews.com/a/1836445.html
连麦专家:2024年到底如何做小红书? :https://www.kjdsnews.com/a/1836446.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流