wtsapi32.WTSQuerySessionInformation() 在 x64 上失败
我正在尝试收集 64 位 Windows 计算机上的终端服务器会话信息。 我的问题有两个方面。 首先,在 32 位机器上我们调用了以下函数,效果很好。
Private Declare Function WTSQuerySessionInformation Lib "wtsapi32" _
Alias "WTSQuerySessionInformationA" _
(ByVal hServer As Integer, _
ByVal SessionID As Integer, _
ByVal WTSInfoClass As Integer, _
ByRef ppBuffer As String, _
ByRef lLen As Integer) As Integer
然而,在 64 位机器上,此函数调用失败。 有谁知道如何解决这个问题? 我用谷歌搜索了一下,但找不到太多关于在 64 位机器上调用这个函数的信息。 其次,有谁知道获取 TS 客户端会话信息的其他选项吗? 具体来说,我需要访问 TS 的计算机名称。
非常感谢您的帮助。
I'm trying gather Terminal Server session information on 64-bit Windows machines. My question is two fold. First, on 32-bit machines we called the following function, which worked fine.
Private Declare Function WTSQuerySessionInformation Lib "wtsapi32" _
Alias "WTSQuerySessionInformationA" _
(ByVal hServer As Integer, _
ByVal SessionID As Integer, _
ByVal WTSInfoClass As Integer, _
ByRef ppBuffer As String, _
ByRef lLen As Integer) As Integer
On 64-bit machines however this function call fails. Does anyone have any idea's about how to fix this? I googled around, but couldn't find much about calling this function on a 64 bit machine. Second, does anyone know any other options for getting TS Client Session Info? Specifically I need the Computer Name that is accessing the TS.
Thanks a lot for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 64 位机器上调用失败到底是怎么回事? 我的猜测是,这与您调用该函数的 ANSI 版本有关。 也许您会更幸运地使用 Unicode 版本 (WTSQuerySessionInformationW)。
但要回答你的第二个问题,你可以尝试使用 Cassia 这样你就不必处理P/Invokes:
我不记得我以前是否在 64 位机器上尝试过它,但如果它有效,它可能会让你的事情变得更容易一些。
编辑:刚刚在 64 位 Windows Server 2008 R2 beta 机器上测试了 Cassia,它运行良好。
How exactly is the call failing on the 64-bit machine? My guess is that it has something to do with the fact that you are calling the ANSI version of the function. Perhaps you'd have better luck with the Unicode version (WTSQuerySessionInformationW).
But to answer your second question, you might try using Cassia so that you don't have to deal with the P/Invokes:
I can't remember if I've tried it on a 64-bit machine before, but if it works, it may make things a bit easier for you.
EDIT: Just tested Cassia on a 64-bit Windows Server 2008 R2 beta machine, and it works fine.