Recent

Author Topic: Help me.. Reading output from WinExec()  (Read 10939 times)

Takeda

  • Full Member
  • ***
  • Posts: 157
Help me.. Reading output from WinExec()
« on: July 19, 2011, 04:28:46 am »
Hi..
Today, I try to use WinExec() to call another EXE..
I need help to catch and reading the output from the EXE which I called using WinExec()..  :-*

Help me please... ;)

Regards,
takeda.
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Help me.. Reading output from WinExec()
« Reply #1 on: July 19, 2011, 07:50:16 am »

Takeda

  • Full Member
  • ***
  • Posts: 157
Re: Help me.. Reading output from WinExec()
« Reply #2 on: July 19, 2011, 10:05:44 am »
Thank you very much, Mr. Mario..  ;)

But when I use TProcess or TProcessUTF8, It was failed to work when I passing the CommandLine Parameter which contain UTF8String Character if used in OS which Non UTF8 Character (I mean normal Windows => English). NOTE : I already installing the East Asian Languages (Fonts) too like suggestion in http://wiki.lazarus.freepascal.org/Executing_External_Programs.. My app is working properly if I try to use the language that used in the EXE filename. eg. Korean, in Control Panel -> Regional Languages Options -> Advanced. :'(

Also, I already open thread to get help in http://www.lazarus.freepascal.org/index.php/topic,13865.msg72968.html#msg72968 but not any respond.. So so sad..  :'(

That's the reason, why I prefer to use WinExec() than TProcess or TProcessUTF8.
BTW, Could you help me for Unicode Support??

Regards,
Takeda.
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Help me.. Reading output from WinExec()
« Reply #3 on: July 19, 2011, 01:21:17 pm »
Hi,
i'm not an expert, but in some case i have used "UTF8ToConsole" to "translate" CommandLine Parameter before to use in in TProcess.

Hi, Mario

eny

  • Hero Member
  • *****
  • Posts: 1658
Re: Help me.. Reading output from WinExec()
« Reply #4 on: July 19, 2011, 10:22:46 pm »
The simplest solution is to start cmd.exe with the program as a parameter, send the output to a tempfile ( > temfile.txt) and read that tempfile.
All posts based on: Win11; Lazarus 4_4  (x64) 12-02-2026 (unless specified otherwise...)

Takeda

  • Full Member
  • ***
  • Posts: 157
Re: Help me.. Reading output from WinExec()
« Reply #5 on: July 19, 2011, 11:57:04 pm »
Hi,
i'm not an expert, but in some case i have used "UTF8ToConsole" to "translate" CommandLine Parameter before to use in in TProcess.

Hi, Mario

Yes, of course I did it, Mr. Mario. But it give the same result.. Not any change.. Still failed to working properly..
AFAIK, Since Windows is use native String as their Code Page based, there is so hard for us to tuning-up by passing the Unicode Character into CommandLine.. Sometime coding in Windows make me got headache.. :'(


The simplest solution is to start cmd.exe with the program as a parameter, send the output to a tempfile ( > temfile.txt) and read that tempfile.

Eny, Would you mind to give me more detail.. Please.. I mean The examples.. :)

================
To Mr. Mario and Eny ;

I hear, LCL itself is supporting Unicode but the FreePascal (as based compiler) is not yet support Unicode, so FreePascal is not give us the opportunity to feel the taste of Unicode by providing "Unicode-Ready" in their RTL..

Regards,
Takeda.
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

eny

  • Hero Member
  • *****
  • Posts: 1658
Re: Help me.. Reading output from WinExec()
« Reply #6 on: July 20, 2011, 10:59:15 pm »
I'm not working with Windows at the moment so I can't test it.
But start 'cmd.exe' and give it the parameters ' theprogram.exe > tempfile.txt'
Afterwards you can read tempfile.txt; if the program correctly spools to standard output.
All posts based on: Win11; Lazarus 4_4  (x64) 12-02-2026 (unless specified otherwise...)

Takeda

  • Full Member
  • ***
  • Posts: 157
Re: Help me.. Reading output from WinExec()
« Reply #7 on: July 20, 2011, 11:06:03 pm »
I'm not working with Windows at the moment so I can't test it.
But start 'cmd.exe' and give it the parameters ' theprogram.exe > tempfile.txt'
Afterwards you can read tempfile.txt; if the program correctly spools to standard output.

Ok, I'll test it.. :)
Call me Takeda coz that's my true name.
Pascal coding using Lazarus => "Be native in any where.."

ƪ(˘⌣˘)┐ ƪ(˘⌣˘)ʃ ┌(˘⌣˘)ʃ

 

TinyPortal © 2005-2018