我有一个使用动态虚拟通道的应用程序。在测试中,我发现某些用户有时会失败。 WTSVirtualChannelOpenEx的错误为31。我已经看到有关此问题的另一个问题,但是我使用的是本机C ++,并使用了TRUE常数(我检查过的常数实际上是1),因此此处不适用。另外,它有时可以工作的事实向我暗示,这可能不是代码中的特定错误。我实际上只是重新实现了ECHO通道以测试基础结构。
class WTSVirtualChannelCallback : public IntrusiveRefCount<IWTSVirtualChannelCallback> {
std::unique_ptr<IWTSVirtualChannel, ReleaseDeleter> virtualChannel;
public:
WTSVirtualChannelCallback(std::unique_ptr<IWTSVirtualChannel, ReleaseDeleter> virtualChannel)
: virtualChannel(std::move(virtualChannel)) {}
HRESULT __stdcall OnDataReceived(ULONG cbSize, BYTE *pBuffer) override {
return CheckExceptions([&] {
CheckHRESULT(virtualChannel->Write(cbSize, pBuffer, nullptr));
});
}
HRESULT __stdcall OnClose() override {
return S_OK;
}
};
class WTSListenerCallback : public IntrusiveRefCount<IWTSListenerCallback> {
public:
virtual HRESULT __stdcall OnNewChannelConnection(IWTSVirtualChannel *pChannel, BSTR data, BOOL *pbAccept, IWTSVirtualChannelCallback **ppCallback) override {
return CheckExceptions([&] {
std::unique_ptr<IWTSVirtualChannel, ReleaseDeleter> channel(pChannel);
*pbAccept = TRUE;
*ppCallback = new WTSVirtualChannelCallback(std::move(channel));
});
}
};
class __declspec(uuid("22d36a3c-04b1-4073-af3e-ba926c7a233e")) Plugin : public IntrusiveRefCount<IWTSPlugin> {
public:
HRESULT __stdcall Initialize(IWTSVirtualChannelManager *pChannelMgr) override {
return CheckExceptions([&] {
std::unique_ptr<IWTSVirtualChannelManager, ReleaseDeleter> channelManager(pChannelMgr);
CheckHRESULT(channelManager->CreateListener("Bluewire.Citrix.HardwareInputPlugin", 0, new WTSListenerCallback(), nullptr));
});
}
HRESULT __stdcall Connected() override {
return S_OK;
}
HRESULT __stdcall Disconnected(DWORD dwDisconnectCode) override {
return S_OK;
}
HRESULT __stdcall Terminated() override {
return S_OK;
}
};
我遇到了很多人报告Windows Server 2012的问题,但是这里涉及的所有计算机都是Win10或Win7-所有台式机版本。
有什么建议可以解决这里的问题吗?