Reputation: 11
I am working on virtual channels(using C#) using Vanara.PInvoke and I am getting Invalid/null channelHandle.
I check few threads in ChatGpt/Copilot. Also did research on google for any documentation using Vanara.PInvoke. For any reason it is giving Invalid Channel for method WTSVirtualChannelOpenEx.
ChatGpt asked me to validate Session and Virtual Channel Name registration. I am passing WTS_CURRENT_SESSION and for VC, I have registrated in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Addins path(in VM where I need to transfer file) in regedit as per Microsoft website. Still the issue persists.
Please let me know, if anything is missing or need to check in any other direction.
Registered the Virtual Channel HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Addins and passed WTS_CURRENT_SESSION to method WTSVirtualChannelOpenEx. Tried all possible P&C but all returned null/Invalid Channel Handle
Following is sample method that always return Invalid channelHandle.
// Open the virtual channel
channelHandle = WTSVirtualChannelOpenEx(
WTS_CURRENT_SESSION,
Constants.ChannelName,
WTS_CHANNEL_OPTION.WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW);
if (channelHandle == IntPtr.Zero)
{
Console.WriteLine($"Failed to open virtual channel. Error: {GetLastError()}");
return false;
}
here GetLastError return ERROR_SUCCESS but channelHandle return 0x00000000(which is Invalid channelHandle)
Upvotes: 1
Views: 31