Library Project1;
Uses
Windows
Sysutils,
Msodsapi;
... {$R *.res}
Function Getparamstr (Psrvproc:srv_proc; Index:integer; Var param:string): integer;
Var
Ptype:byte;
Cbmaxlen, Paralen:dword;
Isnull:bool;
Begin
Result: = No_error;
Srv_paraminfo (Psrvproc, Index, @PType, @cbMaxLen, @ParaLen, NIL, @IsNULL);
If ptype in [Srvtext,srvvarchar,srvchar,srvntext,
Srvbigvarchar,srvbigchar,srvnvarchar,srvnchar] Then
Begin
Param: = ';
If Paralen>0 then BEGIN
SetLength (Param, Paralen);
Srv_paraminfo (Psrvproc, Index, @PType, @cbMaxLen, @ParaLen, @Param [1], @IsNULL);
End
End
ELSE begin
Result: =-1;
End
End
Function Eppackfile (Psrvproc:srv_proc): integer;cdecl;
Var
ls1,ls2,ls3:string;
N:integer;
Begin
Result: = 1;
N: = Srv_rpcparams (Psrvproc);
If n <> 3 then BEGIN
is not a 3 parameter
End
if (Getparamstr (PSRVPROC,1,LS1) <>no_error) THEN BEGIN
Not a string
End
if (Getparamstr (PSRVPROC,2,LS2) <>no_error) THEN BEGIN
Not a string
End
if (Getparamstr (PSRVPROC,3,LS3) <>no_error) THEN BEGIN
Not a string
End
N: = Length (LS1);
Srv_describe (Psrvproc, 1, ' Parameters ', Srv_nullterm, Srvbigvarchar,
N, Srvbigvarchar, N, NIL);
Srv_setcoldata (Psrvproc, 1, @ls1 [1]);
Srv_sendrow (PSRVPROC);
Srv_setcoldata (Psrvproc, 1, @ls2 [1]);
Srv_sendrow (PSRVPROC);
Srv_setcoldata (Psrvproc, 1, @ls3 [1]);
Srv_sendrow (PSRVPROC);
Srv_senddone (Psrvproc, (Srv_done_count or Srv_done_more), 0, 1);
End
Exports
Eppackfile Name ' Xp_eppackfile ';
Begin
End.
After compiling, put the Binn directory, add and test in SQL, the code is as follows:
Use Master;
IF object_id('xp_EpPackFile') IS NOT NULL EXEC sp_dropextendedproc 'xp_EpPackFile';
EXEC sp_addextendedproc 'xp_EpPackFile', 'project1.dll';
EXEC master..xp_EpPackFile 'aa','bb','cc';
EXEC sp_dropextendedproc 'xp_EpPackFile';
DBCC SPEncrypt(FREE);