登录在远程桌面,如何获得自己登录进来的ID

hpamweeq53 2010-09-24 08:35:08
在登入远程之后,
在任务管理器的最右边,有个用户名,和ID

因为我想判断我这个ID有没有打开一个进程.

在进程里面有ID号的,但没有用户名,

怎么获取到ID号对应的用户名,或怎么获取用户名对应的ID号?



代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sprocesses() As System.Diagnostics.Process
Dim sprocess As System.Diagnostics.Process
Dim s As String
On Error GoTo errorhandler

sprocesses = System.Diagnostics.Process.GetProcesses()
s = ""
s = vbCrLf & "procss info " & vbCrLf

For Each sprocess In sprocesses
s = s & sprocess.Id & Space(5) & sprocess.ProcessName() & sprocess.SessionId & vbCrLf
Next

TextBox1.Text = s
errorhandler:
MsgBox("unexpected error occurred")
End Sub
...全文
502 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
迈克揉索芙特 2010-10-02
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20091010/09/58c182ff-b4f4-4907-9077-c5c3faa4d1d5.html
Tosp2012 2010-10-01
  • 打赏
  • 举报
回复
幫頂一下
lovetow 2010-09-30
  • 打赏
  • 举报
回复
WTSQuerySessionInformation &MSDN
hpamweeq53 2010-09-25
  • 打赏
  • 举报
回复
有没有人帮帮我,急啊!~
hpamweeq53 2010-09-25
  • 打赏
  • 举报
回复
4楼能不能说详细点?
beg200710 2010-09-25
  • 打赏
  • 举报
回复
学习~~
蒋晟 2010-09-25
  • 打赏
  • 举报
回复
WTSQuerySessionInformation
hpamweeq53 2010-09-25
  • 打赏
  • 举报
回复
二楼的再帮帮我!
hpamweeq53 2010-09-24
  • 打赏
  • 举报
回复
楼上的没看懂,
我是想知道我现在登录的.是哪个PID

wuyq11 2010-09-24
  • 打赏
  • 举报
回复
Private Function GetProcessUserName(pID As Integer) As String
Dim s As String = Nothing
Dim query1 As New SelectQuery("Select * from Win32_Process" & pID)
Dim searcher1 As New ManagementObjectSearcher(query1)
Try
For Each disk As ManagementObject In searcher1.[Get]()
Dim inPar As ManagementBaseObject = Nothing
Dim outPar As ManagementBaseObject = Nothing
inPar = disk.GetMethodParameters("GetOwner")
outPar = disk.InvokeMethod("GetOwner", inPar, Nothing)
s+= disk("ProcessId").ToString() + outPar("User") + outPar("Domain")
Next
Catch e As Exception
s= e.Message
End Try
Return s
End Function
http://topic.csdn.net/u/20100802/18/b9fa308b-d752-43d9-8c6a-ee7003f42cac.html

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧