Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net wtsapi32.WTSQuerySessionInformation()在x64上失败_.net_Winapi_Terminal Services - Fatal编程技术网

.net wtsapi32.WTSQuerySessionInformation()在x64上失败

.net wtsapi32.WTSQuerySessionInformation()在x64上失败,.net,winapi,terminal-services,.net,Winapi,Terminal Services,我正在尝试收集64位Windows计算机上的终端服务器会话信息。我的问题有两个方面。首先,在32位机器上,我们调用了以下函数,该函数运行良好 Private Declare Function WTSQuerySessionInformation Lib "wtsapi32" _ Alias "WTSQuerySessionInformationA" _ (ByVal hServer As Integer, _

我正在尝试收集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的计算机名


非常感谢您的帮助。

在64位机器上,呼叫到底是如何失败的?我的猜测是,这与调用函数的ANSI版本有关。也许使用Unicode版本(WTSQuerySessionInformationW)会更幸运

但是为了回答第二个问题,您可以尝试使用,这样就不必处理p/Invokes:

New Cassia.TerminalServicesManager().CurrentSession.ClientName
我不记得我以前是否在64位机器上尝试过,但如果它能工作,可能会让你更容易


编辑:刚刚在64位Windows Server 2008 R2 beta计算机上测试了Cassia,它工作正常。

在64位计算机上调用失败的具体原因是什么?我的猜测是,这与调用函数的ANSI版本有关。也许使用Unicode版本(WTSQuerySessionInformationW)会更幸运

但是为了回答第二个问题,您可以尝试使用,这样就不必处理p/Invokes:

New Cassia.TerminalServicesManager().CurrentSession.ClientName
我不记得我以前是否在64位机器上尝试过,但如果它能工作,可能会让你更容易

编辑:刚刚在64位WindowsServer2008R2测试版机器上测试了Cassia,它工作正常