Recent

Author Topic: linklib the dll file,how to get stdout  (Read 1944 times)

tianya

  • New Member
  • *
  • Posts: 25
linklib the dll file,how to get stdout
« on: April 15, 2018, 03:16:55 am »
the dll file has print some info to stdout,how do i get the stdout into the memo.

Code: Pascal  [Select][+][-]
  1. implementation
  2.  
  3. procedure runServer;cdecl;external;
  4. procedure stopServer;cdecl;external;
  5.  
  6. procedure TForm1.Button1Click(Sender: TObject);
  7. begin
  8.   runServer; <--How to get stdout to memo?
  9. end;  
  10.  
  11.  

tianya

  • New Member
  • *
  • Posts: 25
Re: linklib the dll file,how to get stdout
« Reply #1 on: April 17, 2018, 04:47:51 pm »
Code: C  [Select][+][-]
  1. void runServer(){
  2.     fprintf( stdout, "hello runServer\n" );
  3. }
  4.  

how to get "hello runServer\n" in lazarus?

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: linklib the dll file,how to get stdout
« Reply #2 on: April 17, 2018, 04:53:51 pm »
try something like this ?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: linklib the dll file,how to get stdout
« Reply #3 on: April 17, 2018, 04:54:33 pm »
1 Hook the runtime system of the DLL (which apparently is in some foreign language) Consult your products manual on how to do that.

2 redirect/obtain the output from that runtime system to a pchar.

3 convert the pchar to a pascal string.

4. add the string to memo.

tianya

  • New Member
  • *
  • Posts: 25
Re: linklib the dll file,how to get stdout
« Reply #4 on: April 17, 2018, 05:07:35 pm »
thanks @molly @marcov,i have a try

 

TinyPortal © 2005-2018