How to Layered Service Provider ?


2003-08-29 06:21:11 PM
delphi12
Hi,
I tty to implement a Layered Service Provider in delphi
I have a example for it, but is write un c. :(
I get a jedi win32api translation
I started has to translate the procedure of provider installation
but i have a pointer error and installation not match
//***** Install_My_Layer
Function InstallMyProvider(Var CatalogId: DWORD; ProviderDllPath: String):
Integer;
var
proto_info : LPWSAPROTOCOL_INFOW;
Install_Result : Integer;
Install_Error : Integer;
LayeredProviderGuid: TGUID;
pwProviderDllPath : PWideChar;
pwSize : Integer;
begin
LayeredProviderGuid := GetLayeredProviderGuid;
// Create a PROTOCOL_INFO to install for our provider DLL.
proto_info.dwServiceFlags1 := 0;
proto_info.dwServiceFlags2 := 0;
proto_info.dwServiceFlags3 := 0;
proto_info.dwServiceFlags4 := 0;
proto_info.dwProviderFlags := PFL_HIDDEN;
proto_info.ProviderId := LayeredProviderGuid;
proto_info.dwCatalogEntryId := 0;
proto_info.ProtocolChain.ChainLen := LAYERED_PROTOCOL;
proto_info.iVersion := 0;
proto_info.iAddressFamily := AF_INET;
proto_info.iMaxSockAddr := 16;
proto_info.iMinSockAddr := 16;
proto_info.iSocketType := SOCK_STREAM;
proto_info.iProtocol := IPPROTO_TCP;
proto_info.iProtocolMaxOffset := 0;
proto_info.iNetworkByteOrder := BIGENDIAN;
proto_info.iSecurityScheme := SECURITY_PROTOCOL_NONE;
proto_info.dwMessageSize := 0;
proto_info.dwProviderReserved := 0;
wcscpy(proto_info.szProtocol, LAYERED_PROVIDER_NAME);
pwProviderDllPath := nil;
pwSize := Length(ProviderDllPath);
pwProviderDllPath := StringToPWide(ProviderDllPath, pwSize);
// Original function in JwaWS2spi.pas jedi
// function WSCInstallProvider(const lpProviderId: TGUID;
lpszProviderDllPath: PWCHAR;
// lpProtocolInfoList: LPWSAPROTOCOL_INFOW; dwNumberOfEntries: DWORD; var
lpErrno: Integer): Integer; stdcall;
Install_Result := WSCInstallProvider(LayeredProviderGuid,
pwProviderDllPath, //
lpszProviderDllPath
proto_info, //
lpProtocolInfoList
1, //
dwNumberOfEntries
Install_Error); // lpErrno
CatalogId := proto_info.dwCatalogEntryId;
Result := Install_Result;
proto_info:=Nil;
end;
have an idea?
Thanks