Home > Back-end >  Delphi wrote a post request subroutine, I want to build into a DLL, ask god for help.
Delphi wrote a post request subroutine, I want to build into a DLL, ask god for help.

Time:09-26

Have not learned the Delphi, only know how to write a simple DLL, hope god can give the subroutine, after I copy and paste can be compiled into a DLL!
The following is the function definition:
 
The function countnum (url: String, FileName: String, param: String) : String; Stdcall; Export;

End.

As shown in figure: Delphi a great god grant instruction.

CodePudding user response:

 
The library Project1.


USES the
SysUtils IdBaseComponent, IdComponent IdTCPConnection, IdTCPClient,
IdHTTP Classes;

The function countnum (url, FileName, param: String) : String; Stdcall;
Var
HTTP: TIdHTTP;
ParamPost: TStringList;
The begin
HTTP:=TIdHTTP. Create (nil);

ParamPost:=TStringList. The Create ();
Try
ParamPost. Add (param);
HTTP. ReadTimeout: 30 *=1000;
Result:=HTTP Post (url + FileName, ParamPost);
The finally
FreeAndNil (HTTP).
ParamPost. Free ();
The end;

The end;
The end;

{$R *. Res}
Exports
Countnum;
The begin
End.



The above code untested, but compilation should be error free
  • Related