📄 usbiocomlib_tlb.pas
字号:
procedure StartReading(SizeOfBuffer_IsoFramesInBuffer: SYSINT; NumberOfBuffers: SYSINT;
MaxErrorCount: SYSINT; out Status: SYSINT);
procedure ReadData(var Buffer: PSafeArray; out ByteCount: SYSINT; out Status: SYSINT);
procedure ReadIsoData(var Buffer: PSafeArray; out ByteCount: SYSINT;
var SubBufferLength_ErrorCode: PSafeArray; out Status: SYSINT);
procedure StopReading;
procedure StartWriting(SizeOfBuffer_IsoFramesInBuffer: SYSINT; NumberOfBuffers: SYSINT;
MaxErrorCount: SYSINT; WriteStatus: Integer; out Status: SYSINT);
procedure WriteData(var Buffer: PSafeArray; UserId: SYSINT; out Status: SYSINT);
procedure GetWriteStatus(out UserId: SYSINT; out Status: SYSINT);
procedure WriteIsoData(var Buffer: PSafeArray; var SubBufferLength: PSafeArray; UserId: SYSINT;
out Status: SYSINT);
procedure GetIsoWriteStatus(out UserId: SYSINT; var StatusArray: PSafeArray;
out FrameCount: SYSINT; out Status: SYSINT);
procedure StopWriting;
procedure ResetPipe(out Status: SYSINT);
procedure AbortPipe(out Status: SYSINT);
procedure EnablePnPNotification(const Guid: WideString; out Status: SYSINT);
procedure DisablePnPNotification(const Guid: WideString; out Status: SYSINT);
property DefaultInterface: IUSBIOInterface read GetDefaultInterface;
property DevicePathName: WideString read Get_DevicePathName;
property IsCheckedBuild: Integer read Get_IsCheckedBuild;
property IsDemoVersion: Integer read Get_IsDemoVersion;
property IsLightVersion: Integer read Get_IsLightVersion;
property EndpointFifoSize: SYSINT read Get_EndpointFifoSize;
property DeviceOptions: SYSINT read Get_DeviceOptions write Set_DeviceOptions;
property DeviceRequestTimeout: SYSINT read Get_DeviceRequestTimeout write Set_DeviceRequestTimeout;
property ShortTransferOK: Integer read Get_ShortTransferOK write Set_ShortTransferOK;
published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
property Server: TUSBIOInterfaceProperties read GetServerProperties;
{$ENDIF}
property OnReadComplete: TUSBIOInterfaceReadComplete read FOnReadComplete write FOnReadComplete;
property OnWriteComplete: TUSBIOInterfaceWriteComplete read FOnWriteComplete write FOnWriteComplete;
property OnWriteStatusAvailable: TUSBIOInterfaceWriteStatusAvailable read FOnWriteStatusAvailable write FOnWriteStatusAvailable;
property OnPnPAddNotification: TUSBIOInterfacePnPAddNotification read FOnPnPAddNotification write FOnPnPAddNotification;
property OnPnPRemoveNotification: TUSBIOInterfacePnPRemoveNotification read FOnPnPRemoveNotification write FOnPnPRemoveNotification;
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object : TUSBIOInterface
// (This object is used by the IDE's Property Inspector to allow editing
// of the properties of this server)
// *********************************************************************//
TUSBIOInterfaceProperties = class(TPersistent)
private
FServer: TUSBIOInterface;
function GetDefaultInterface: IUSBIOInterface;
constructor Create(AServer: TUSBIOInterface);
protected
function Get_DevicePathName: WideString;
function Get_IsCheckedBuild: Integer;
function Get_IsDemoVersion: Integer;
function Get_IsLightVersion: Integer;
function Get_DeviceOptions: SYSINT;
procedure Set_DeviceOptions(Options: SYSINT);
function Get_DeviceRequestTimeout: SYSINT;
procedure Set_DeviceRequestTimeout(pVal: SYSINT);
function Get_ShortTransferOK: Integer;
procedure Set_ShortTransferOK(ShortTransfer: Integer);
function Get_EndpointFifoSize: SYSINT;
public
property DefaultInterface: IUSBIOInterface read GetDefaultInterface;
published
property DeviceOptions: SYSINT read Get_DeviceOptions write Set_DeviceOptions;
property DeviceRequestTimeout: SYSINT read Get_DeviceRequestTimeout write Set_DeviceRequestTimeout;
property ShortTransferOK: Integer read Get_ShortTransferOK write Set_ShortTransferOK;
end;
{$ENDIF}
procedure Register;
implementation
uses ComObj;
class function CoUSBIOInterface.Create: IUSBIOInterface;
begin
Result := CreateComObject(CLASS_USBIOInterface) as IUSBIOInterface;
end;
class function CoUSBIOInterface.CreateRemote(const MachineName: string): IUSBIOInterface;
begin
Result := CreateRemoteComObject(MachineName, CLASS_USBIOInterface) as IUSBIOInterface;
end;
procedure TUSBIOInterface.InitServerData;
const
CServerData: TServerData = (
ClassID: '{9FCAC6CD-1440-4ABD-8997-13C42201A20B}';
IntfIID: '{666A2128-A89C-4166-8683-59D0628E227D}';
EventIID: '{1553C229-9FA0-4E20-A66E-EA2F28C35A49}';
LicenseKey: nil;
Version: 500);
begin
ServerData := @CServerData;
end;
procedure TUSBIOInterface.Connect;
var
punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk as IUSBIOInterface;
end;
end;
procedure TUSBIOInterface.ConnectTo(svrIntf: IUSBIOInterface);
begin
Disconnect;
FIntf := svrIntf;
ConnectEvents(FIntf);
end;
procedure TUSBIOInterface.DisConnect;
begin
if Fintf <> nil then
begin
DisconnectEvents(FIntf);
FIntf := nil;
end;
end;
function TUSBIOInterface.GetDefaultInterface: IUSBIOInterface;
begin
if FIntf = nil then
Connect;
Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
Result := FIntf;
end;
constructor TUSBIOInterface.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps := TUSBIOInterfaceProperties.Create(Self);
{$ENDIF}
end;
destructor TUSBIOInterface.Destroy;
begin
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps.Free;
{$ENDIF}
inherited Destroy;
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
function TUSBIOInterface.GetServerProperties: TUSBIOInterfaceProperties;
begin
Result := FProps;
end;
{$ENDIF}
procedure TUSBIOInterface.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnReadComplete) then
FOnReadComplete(Self, Params[0] {const IDispatch});
2: if Assigned(FOnWriteComplete) then
FOnWriteComplete(Self, Params[0] {const IDispatch});
3: if Assigned(FOnWriteStatusAvailable) then
FOnWriteStatusAvailable(Self, Params[0] {const IDispatch});
4: if Assigned(FOnPnPAddNotification) then
FOnPnPAddNotification(Self, Params[0] {const IDispatch});
5: if Assigned(FOnPnPRemoveNotification) then
FOnPnPRemoveNotification(Self, Params[0] {const IDispatch});
end; {case DispID}
end;
function TUSBIOInterface.Get_DevicePathName: WideString;
begin
Result := DefaultInterface.Get_DevicePathName;
end;
function TUSBIOInterface.Get_IsCheckedBuild: Integer;
begin
Result := DefaultInterface.Get_IsCheckedBuild;
end;
function TUSBIOInterface.Get_IsDemoVersion: Integer;
begin
Result := DefaultInterface.Get_IsDemoVersion;
end;
function TUSBIOInterface.Get_IsLightVersion: Integer;
begin
Result := DefaultInterface.Get_IsLightVersion;
end;
function TUSBIOInterface.Get_DeviceOptions: SYSINT;
begin
Result := DefaultInterface.Get_DeviceOptions;
end;
procedure TUSBIOInterface.Set_DeviceOptions(Options: SYSINT);
begin
DefaultInterface.Set_DeviceOptions(Options);
end;
function TUSBIOInterface.Get_DeviceRequestTimeout: SYSINT;
begin
Result := DefaultInterface.Get_DeviceRequestTimeout;
end;
procedure TUSBIOInterface.Set_DeviceRequestTimeout(pVal: SYSINT);
begin
DefaultInterface.Set_DeviceRequestTimeout(pVal);
end;
function TUSBIOInterface.Get_ShortTransferOK: Integer;
begin
Result := DefaultInterface.Get_ShortTransferOK;
end;
procedure TUSBIOInterface.Set_ShortTransferOK(ShortTransfer: Integer);
begin
DefaultInterface.Set_ShortTransferOK(ShortTransfer);
end;
function TUSBIOInterface.Get_EndpointFifoSize: SYSINT;
begin
Result := DefaultInterface.Get_EndpointFifoSize;
end;
procedure TUSBIOInterface.EnumerateDevices(const GUIDDriverInterface: WideString;
out NumberOfDevices: SYSINT);
begin
DefaultInterface.EnumerateDevices(GUIDDriverInterface, NumberOfDevices);
end;
procedure TUSBIOInterface.OpenDevice(DeviceNumber: SYSINT; out Status: SYSINT);
begin
DefaultInterface.OpenDevice(DeviceNumber, Status);
end;
procedure TUSBIOInterface.CloseDevice;
begin
DefaultInterface.CloseDevice;
end;
procedure TUSBIOInterface.GetDriverInfo(out APIVersion: SYSINT; out DriverVersion: SYSINT;
out DriverBuildNumber: SYSINT; out Flags: SYSINT;
out Status: SYSINT);
begin
DefaultInterface.GetDriverInfo(APIVersion, DriverVersion, DriverBuildNumber, Flags, Status);
end;
procedure TUSBIOInterface.GetDescriptor(var Descriptor: PSafeArray; var DescSize: SYSINT;
Recipient: SYSINT; DescriptorType: SYSINT;
DescriptorIndex: SYSINT; LanguageId: SYSINT;
out Status: SYSINT);
begin
DefaultInterface.GetDescriptor(Descriptor, DescSize, Recipient, DescriptorType, DescriptorIndex,
LanguageId, Status);
end;
procedure TUSBIOInterface.GetDeviceDescriptor(var DeviceDescriptor: PSafeArray;
var DescSize: SYSINT; out Status: SYSINT);
begin
DefaultInterface.GetDeviceDescriptor(DeviceDescriptor, DescSize, Status);
end;
procedure TUSBIOInterface.GetConfigurationDescriptor(var ConfigDescriptor: PSafeArray;
var DescSize: SYSINT; Index: Byte;
out Status: SYSINT);
begin
DefaultInterface.GetConfigurationDescriptor(ConfigDescriptor, DescSize, Index, Status);
end;
procedure TUSBIOInterface.GetStringDescriptor(var StringDescriptor: PSafeArray;
var DescSize: SYSINT; Index: Byte;
LanguageId: SYSINT; out Status: SYSINT);
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -