public static PcanStatus GetAttachedChannels(
out PcanChannelInformation[] buffer
)
Public Shared Function GetAttachedChannels (
<OutAttribute> ByRef buffer As PcanChannelInformation()
) As PcanStatus
public:
static PcanStatus GetAttachedChannels(
[OutAttribute] array<PcanChannelInformation^>^% buffer
)
The return value is a PcanStatus value. OK is returned on success.
The method GetAttachedChannels is an aid that internally calls the method GetValue to get the amount of attached PCAN Channels and their description as an array of PcanChannelInformation objects.
The involved PCAN parameters are AttachedChannelsCount and AttachedChannelsInformation.
The following example shows the use of the GetAttachedChannels method to retrieve and show the name, PCAN Channel handle, and features of all current attached PCAN devices.
// A list with all registered channels is retrieved
//
PcanStatus result = Api.GetAttachedChannels(out var channels);
if (result != PcanStatus.OK)
{
// An error occurred
//
Api.GetErrorText(result, out var errorText);
Console.WriteLine(errorText);
}
else
{
// The information about the registered hardware is shown
//
if (channels.Length == 0)
Console.WriteLine("There are currently no PCAN devices attached to the system...");
else
foreach (PcanChannelInformation channelInfo in channels)
Console.WriteLine($"{channelInfo.DeviceName} (0x{channelInfo.ChannelHandle:X}): {channelInfo.DeviceFeatures}");
}
Dim result As PcanStatus
Dim channels As PcanChannelInformation() = Nothing
' A list with all registered channels Is retrieved
'
result = Api.GetAttachedChannels(channels)
If (result <> PcanStatus.OK) Then
' An error occurred
'
Dim errorText As String = String.Empty
Api.GetErrorText(result, errorText)
Console.WriteLine(errorText)
Else
' The information about the registered hardware is shown
'
If (channels.Length = 0) Then
Console.WriteLine("There are currently no PCAN devices attached to the system...")
Else
For Each channelInfo As PcanChannelInformation In channels
Console.WriteLine($"{channelInfo.DeviceName} (0x{channelInfo.ChannelHandle:X}): {channelInfo.DeviceFeatures}")
Next
End If
End If
String^ errorText;
PcanStatus result;
array<PcanChannelInformation^>^ channels;
// A list with all registered channels is retrieved
//
result = Api::GetAttachedChannels(channels);
if (result != PcanStatus::OK)
{
// An error occurred
//
Api::GetErrorText(result, errorText);
Console::WriteLine(errorText);
}
else
{
// The information about the registered hardware is shown
//
if (channels->Length == 0)
Console::WriteLine("There are currently no PCAN devices attached to the system...");
else
for each (PcanChannelInformation^ channelInfo in channels)
{
Console::WriteLine("{0} (0x{1:X}): {2}", channelInfo->DeviceName, channelInfo->ChannelHandle, channelInfo->DeviceFeatures);
}
}
DllNotFoundException | The underlying PCANBasic.dll library could not be found. |