Article View: borland.public.cppbuilder.nativeapi
Article #9937Re: Controlling another application
From: Daniele Borini
Date: Mon, 31 May 2004 22:18
Date: Mon, 31 May 2004 22:18
57 lines
2895 bytes
2895 bytes
10X, i'm just trying to taking control of another process, the easyest
way to do that is handling dir *.* i/o.. just the first step of the
stairway (to heaven has someone sang)..
Remy Lebeau (TeamB) ha scritto:
> "Daniele Borini" <borini@infinito.it> wrote in message
> news:40bb1e04@newsgroups.borland.com...
>
>
>>this is my code:
>
>
> Use this code instead:
>
> {
> HANDLE hStdInRead = NULL;
> HANDLE hStdInWrite = NULL;
> HANDLE hStdOutRead = NULL;
> HANDLE hStdOutWrite = NULL;
>
> if( CreatePipe(&hStdInRead, &hStdInWrite, NULL, 10000) )
> {
> if( CreatePipe(&hStdOutRead, &hStdOutWrite, NULL, 10000) )
> {
> STARTUPINFO sInfo = {0};
> PROCESSINFO pInfo = {0};
>
> sInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
> sInfo.wShowWindow = SW_NORMAL;
> sInfo.hStdInput = hStdInRead;
> sInfo.hStdOutput = hStdOutWrite;
> sInfo.hStdError = hStdOutWrite;
>
> if( CreateProcess(NULL, "cmd.exe", NULL, NULL, TRUE,
> NORMAL_PRIORITY_CLASS, NULL, NULL, &sInfo, &pInfo) )
> {
> WriteFile(hStdInWrite, dir *.*\n, 8, &i, NULL);
>
> DWORD i = 0;
> char str_out[10000] = {0};
> ReadFile(hStdOutRead, str_out, sizeof(str_out), &i,
> NULL);
>
> Display->Lines->Add(str_out);
> }
> }
> }
> }
>
> Even better, for a directory listing you really should be using
> FindFirstFile(), FindNextFile(), and FileClose() instead. Then you don't
> need CreateProcess() at all.
>
>
> Gambit
>
>
Technical Details
Message-ID:
<40bbaf53$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40b882fd@newsgroups.borland.com> <40b8ec28$1@newsgroups.borland.com> <40bb1e04@newsgroups.borland.com> <40bbabcd$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5907943efec0dea8 X-Google-Attributes: gid10cc67,public Date: Tue, 01 Jun 2004 00:18:53 +0200 From: Daniele Borini <borini@infinito.it> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.6) Gecko/20040113 X-Accept-Language: it, en, en-us MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Controlling another application References: <40b882fd@newsgroups.borland.com> <40b8ec28$1@newsgroups.borland.com> <40bb1e04@newsgroups.borland.com> <40bbabcd$1@newsgroups.borland.com> In-Reply-To: <40bbabcd$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 62.94.67.130 Message-ID: <40bbaf53$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1086041939 62.94.67.130 (31 May 2004 15:18:59 -0700) Lines: 57 Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail