Delphi :)
7 отговора
0 прегледа
Delphi :)
abe imam edin problem - iskam da si puskam ot moita programa (na Delphi) edin dosowski pkzip, koito da e kato modalen, smisyl da ne moje da se shtraka po moita programka, dokato ne swyrshi pkzip-a....
ima li niakoi ideia, znam che moje da stane, no neshto se ebawa :((
ima li niakoi ideia, znam che moje da stane, no neshto se ebawa :((
Re: Delphi :)
Това го взех от едно демо в Torry.ru
{*****************************[ RUNPROCESS ] ***********************************
*
* Type: Function
* Use: To launch an application and optionally wait until the launched
* Application is terminated before running the rest of the code.
*
* PARAMETERS:
*
* AppPath: The full path and Application Name to run ie. c:\winnt\notepad.exe
*
* AppParams: Commandline params to send to the app.
*
* Visibility:
* Can have any of the following values:
* Value Meaning
* SW_HIDE Hides the window and activates another window.
* SW_MAXIMIZE Maximizes the specified window.
* SW_MINIMIZE Minimizes the specified window and activates the next top-level
* window in the Z order.
* SW_RESTORE Activates and displays the window. If the window is minimized or
* maximized, Windows restores it to its original size and position. An
* application should specify this flag when restoring a minimized window.
* SW_SHOW Activates the window and displays it in its current size and position.
* SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the
* STARTUPINFO structure passed to the CreateProcess function by the program
* that started the application.
* SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
* SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
* SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active
* window remains active.
* SW_SHOWNA Displays the window in its current state. The active window remains
* active.
* SW_SHOWNOACTIVATE Displays a window in its most recent size and position.
* The active window remains active.
* SW_SHOWNORMAL Activates and displays a window. If the window is minimized or
* maximized, Windows restores it to its original size and position. An
* application should specify this flag when displaying the window for the
* first time.
*
* MustWait: true if the code must be paused until the termination of the launched
* Application. false if the code must run directly after launching the app.
*
********************************************************************************}
function TForm1.RunProcess(const AppPath, AppParams: string;
Visibility: Word; MustWait: Boolean): DWord;
var
SI: TStartupInfo;
PI: TProcessInformation;
Proc: THandle;
begin
FillChar(SI, SizeOf(SI), 0);
SI.cb := SizeOf(SI);
SI.wShowWindow := Visibility;
if not CreateProcess(PChar(AppPath), PChar(AppParams), nil, nil, false, Normal_Priority_Class, nil, nil, SI, PI) then
raise Exception.CreateFmt('Failed to excecute program. Error Code %d', [GetLastError]);
Proc := PI.hProcess;
CloseHandle(PI.hThread);
if MustWait then
if WaitForSingleObject(Proc, Infinite) <> Wait_Failed then
GetExitCodeProcess(Proc, Result);
CloseHandle(Proc);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex = 0 then // Must Wait
RunProcess('c:\tools\pkzip.exe','', SW_SHOWNORMAL, true)
else
RunProcess('c:\tools\pkzip.exe','', SW_SHOWNORMAL, false);
ShowMessage('Code after notepad was launched');
end;
Пробвах го. Работи :)
Би трябвало да ти свърши работа.
Препоръчвам ти когато ти трябва нещо да си пуснеш едно [линк]
да си напишеш магическите думички и то ще излезе :)))
В този случй магическите думички бяха:
wait application to terminate delphi
Първото което излезе е:
[линк]
На тази страница виж Lunch Demo
Bye
{*****************************[ RUNPROCESS ] ***********************************
*
* Type: Function
* Use: To launch an application and optionally wait until the launched
* Application is terminated before running the rest of the code.
*
* PARAMETERS:
*
* AppPath: The full path and Application Name to run ie. c:\winnt\notepad.exe
*
* AppParams: Commandline params to send to the app.
*
* Visibility:
* Can have any of the following values:
* Value Meaning
* SW_HIDE Hides the window and activates another window.
* SW_MAXIMIZE Maximizes the specified window.
* SW_MINIMIZE Minimizes the specified window and activates the next top-level
* window in the Z order.
* SW_RESTORE Activates and displays the window. If the window is minimized or
* maximized, Windows restores it to its original size and position. An
* application should specify this flag when restoring a minimized window.
* SW_SHOW Activates the window and displays it in its current size and position.
* SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the
* STARTUPINFO structure passed to the CreateProcess function by the program
* that started the application.
* SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
* SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
* SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active
* window remains active.
* SW_SHOWNA Displays the window in its current state. The active window remains
* active.
* SW_SHOWNOACTIVATE Displays a window in its most recent size and position.
* The active window remains active.
* SW_SHOWNORMAL Activates and displays a window. If the window is minimized or
* maximized, Windows restores it to its original size and position. An
* application should specify this flag when displaying the window for the
* first time.
*
* MustWait: true if the code must be paused until the termination of the launched
* Application. false if the code must run directly after launching the app.
*
********************************************************************************}
function TForm1.RunProcess(const AppPath, AppParams: string;
Visibility: Word; MustWait: Boolean): DWord;
var
SI: TStartupInfo;
PI: TProcessInformation;
Proc: THandle;
begin
FillChar(SI, SizeOf(SI), 0);
SI.cb := SizeOf(SI);
SI.wShowWindow := Visibility;
if not CreateProcess(PChar(AppPath), PChar(AppParams), nil, nil, false, Normal_Priority_Class, nil, nil, SI, PI) then
raise Exception.CreateFmt('Failed to excecute program. Error Code %d', [GetLastError]);
Proc := PI.hProcess;
CloseHandle(PI.hThread);
if MustWait then
if WaitForSingleObject(Proc, Infinite) <> Wait_Failed then
GetExitCodeProcess(Proc, Result);
CloseHandle(Proc);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex = 0 then // Must Wait
RunProcess('c:\tools\pkzip.exe','', SW_SHOWNORMAL, true)
else
RunProcess('c:\tools\pkzip.exe','', SW_SHOWNORMAL, false);
ShowMessage('Code after notepad was launched');
end;
Пробвах го. Работи :)
Би трябвало да ти свърши работа.
Препоръчвам ти когато ти трябва нещо да си пуснеш едно [линк]
да си напишеш магическите думички и то ще излезе :)))
В този случй магическите думички бяха:
wait application to terminate delphi
Първото което излезе е:
[линк]
На тази страница виж Lunch Demo
Bye
Re: Delphi :)
има няколко много добри мнения по този вапрос просто погледни по-назад в клуба търси "DELPHI - moje bi otgovora e prost no pomognete... " и ще намериш добро решение

Re: Delphi :)
Mersi mnogo, uj se pisha programist na Delphi, ama dosta raboti imam da ponaucha oshte :)))
towa adski mi triabwashe, za da mogat typite patki da si prawiat denonoshten arhiw s pkzip ....
:)
oshte wednyj mersi :))))
towa adski mi triabwashe, za da mogat typite patki da si prawiat denonoshten arhiw s pkzip ....
:)
oshte wednyj mersi :))))
Re: Delphi :)
abe ima samo edin stranen moment - ne znam dali samo pri mene, no sys CreateProcess neshto ne moga da puskam dosowski prilojenia ?!?!?!?!
ne wdiawam neshto ....
sys ShellExecute moga da gi puskam, no ne moga da gi chakam da swyrshat :(((
i oswen towa kak moga da mu kaja 'Close on exit' ??????
stanah li dosaden :P))))
ne wdiawam neshto ....
sys ShellExecute moga da gi puskam, no ne moga da gi chakam da swyrshat :(((
i oswen towa kak moga da mu kaja 'Close on exit' ??????
stanah li dosaden :P))))
Re: Delphi :)
mi sea da te oswetlq po wyprosa za arhiwiraneto:
chuwali li si za onaq magicheska biblioteka narechena ZLIB?? potyrsi i wij - towa e edna sywkupnost ot procedurki (napisani dori i na pascal) za kompresirane na kakwoto se setish - potok fajl bufer i syotwetno razkompresirane t.e. mojesh spokojno da si gi wgrajdash w twoq si god i da ne ti se nalaga da puskash nishto...
Za drugoto e po lesno da chetesh w helpa... tam ima edna magicheska funkciq WaitFor... ta tq izchakwa proesa da zawyrshi Createproces wrysha PID i taka... drugoto e opcii i nishto poweche..
Are kysmet!
chuwali li si za onaq magicheska biblioteka narechena ZLIB?? potyrsi i wij - towa e edna sywkupnost ot procedurki (napisani dori i na pascal) za kompresirane na kakwoto se setish - potok fajl bufer i syotwetno razkompresirane t.e. mojesh spokojno da si gi wgrajdash w twoq si god i da ne ti se nalaga da puskash nishto...
Za drugoto e po lesno da chetesh w helpa... tam ima edna magicheska funkciq WaitFor... ta tq izchakwa proesa da zawyrshi Createproces wrysha PID i taka... drugoto e opcii i nishto poweche..
Are kysmet!
Re: Delphi :)
typoto e, che iskat arhiwa da se prawi nepremenno sys zip, za da mogat dori i w dos da razarhiwirat, kogato triabwa ....
a zashto CreateProcess ne ebawa da mi puska dosowski prilojenia, az li sym typ neshto ..... s notepad stawa, s pkzip, e, f i tam kakwoto se setish - ne :((
a zashto CreateProcess ne ebawa da mi puska dosowski prilojenia, az li sym typ neshto ..... s notepad stawa, s pkzip, e, f i tam kakwoto se setish - ne :((
Re: Delphi :)
:))))))))))
В help-a за CreateProcess пише, че за да подадеш параметри на MS-DOS проложение първия параметър трябва да е името на програмата.
Пробвах това:
RunProcess('c:\tools\pkzip.exe','pkzip exp', SW_SHOWNORMAL, true)
и стана :)
zip архивче с име exp.zip и pkzip се затвори.
Сигурно това ти е проблема.
В help-a за CreateProcess пише, че за да подадеш параметри на MS-DOS проложение първия параметър трябва да е името на програмата.
Пробвах това:
RunProcess('c:\tools\pkzip.exe','pkzip exp', SW_SHOWNORMAL, true)
и стана :)
zip архивче с име exp.zip и pkzip се затвори.
Сигурно това ти е проблема.