Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2002.04.08;
Скачать: [xml.tar.bz2];

Вниз

Как создать процесс с параметром?   Найти похожие ветки 

 
Керик   (2002-02-07 04:51) [0]

Как с помощью CreateProcess(...) Запистить программу с параметром?


 
MBo   (2002-02-07 07:31) [1]

Okay, while the code above works just fine for executing an application, one my readers pointed out that it doesn"t work with programs that include a command line argument. Why? Because CreateProcess" first parameter expects a fully qualified program name (path\executable) and nothing else! In fact, if you include a command line in that parameter, CreateProcess will do nothing. Yikes! In that case, you have to use the second argument. In fact, you can use the second parameter even for just executing a program with no command line. Given that, ExecNewprocess would be changed as follows:
{Supply a fully qualified path name in ProgramName
and any arguments on the command line. As the help file
states: "If lpApplicationName is NULL, the first white space-delimited
token of the command line specifies the module name..." In English,
the characters before the first space encountered (or if no space is
encountered as in a single program call) is interpreted as the
EXE to execute. The rest of the string is the argument line.}
procedure ExecNewProcess(ProgramName : String);
var
StartInfo : TStartupInfo;
ProcInfo : TProcessInformation;
CreateOK : Boolean;
begin

{ fill with known state }
FillChar(StartInfo,SizeOf(TStartupInfo),#0);
FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);

CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False,
CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
nil, nil, StartInfo, ProcInfo);

{ check to see if successful }
if CreateOK then
//may or may not be needed. Usually wait for child processes
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
end;



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2002.04.08;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.006 c
1-22626
Good Man
2002-03-27 19:04
2002.04.08
Подскажите, где взять Grid?


3-22533
rvs
2002-03-14 16:22
2002.04.08
Delphi+MySql ---- начинающий


1-22643
Corte ™
2002-03-28 10:13
2002.04.08
Всем привет.


1-22679
Fran
2002-03-26 10:52
2002.04.08
Нужен компонент типа TrxCalcEdit, но вместо цифр - англ.букв


3-22551
Sergant
2002-03-15 13:12
2002.04.08
Есть ли компонент вроде EasyTable?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский