| |
|
|
|
Description:
declared CreateProcess launch a application.
Deklaration:
Def @CreateProcess(10) !KERNEL32,CreateProcessA
Parameter: 1.Parameter: Memory-Variable, in the the name the To startenden Program standing (can 0 his).
2.Parameter: Memory-Variable, in the The Kommandozeile the To startenden Program standing (way, Dateiname and Parameter). deference! long Filenames make here possible Problems!!!
3.Parameter: Memory-Variable with a Security Descriptor for To startenden Process (can 0 his).
4.Parameter: Memory-Variable with a Security Descriptor for whom first Thread the To startenden Process (can 0 his).
5.Parameter: Flag for übernahme of Handles. can 1 or 0 his.
6.Parameter: Flag for manner the Erzeugung dss Prozesses (can 0 his).
7.Parameter: Zeiger on a new block with Enviroment-Variables. can 0 his.
8.Parameter: Memory-Variable, in the the new actually directory the To startenden Prozesses standing (can 0 his)..
9.Parameter: Structure or 68 byte large Memory-Variable, in the further Information over the Startvorgang the Prozesses stand can. =>
- Byte 0-3 = Size the Bereichs / the Struktur
- Byte 4-7 = mandatory 0 his (reserved).
- Byte 8-11 = 0 or The address one Strings with the names the Desktops, on the the Process created go should. under windows95 becomes this Parameter ignoring..
- Bytes 12-15 = 0 or address the Titels of/ one Konsolenanwendung.
- Byte 16-19 = If the Flag $4 under byte 44 present is, The X-position the begot Fensters the Prozesses. otherwise 0.
- Byte 20-23 = If the Flag $4 under byte 44 present is, The Y-position the begot Fensters the Prozesses. otherwise 0.
- Byte 24-27 = If the Flag $2 under byte 44 present is, The wide the begot Fensters the Prozesses. otherwise 0.
- Byte 28-31 = If the Flag $2 under byte 44 present is, the level the begot Fensters the Prozesses. otherwise 0.
- Byte 32-35 = If the Flag $8 under byte 44 present is, standing here for a Konsolenanwendung The wide the Screen-Buffers in ‚(characters-)Spalten’.
- Byte 36-39 = If the Flag $8 under byte 44 present is, standing here for a Konsolenanwendung The wide the Screen-Buffers in ‚(characters-)Zeilen’.
- Byte 40-43 = ? Happen?, The for Konsolenprozesse The Text- and Hintergrundfarben indicate, . if the Flag $10 under byte 44 present is. otherwise 0.
- Byte 44-47 = ? Happen?, The u.a. indicate which Members the structure/the Bereichs uses go. The ? Happen? can with | add go. =>
$1 = The on byte 48 stehende Flag to display the Fensters becomes uses.
$2 = The on byte 24 and 28 stehenden indicated To Höhe and wide the Fensters go uses.
$4 = The on byte 16 and 20 stehenden indicated to position the Fensters go uses.
$8 = The on byte 32 and 36 stehenden indicated go uses.
$10 = The on byte 40 stehenden go uses.
$40 = shows at construction the Prozesses whom Cursor „Anwendung becomes gestartet“ on.
$80 = Normaler Cursor becomes displayed (contrary of $40).
$100 = using The ex byte 56 angegebenen Handles for Process. moreover must Parameter 5 ditto on 1 staid go.
$80000000 = The Process becomes like a Screensaver treats.
- Byte 48-49 = Abbildungsmodus the Fensters the Prozesses (see 2.Parameter of WinExec in the Profan Help).
- Byte 50-51 = reserved, must 0 his.
- Byte 52-55 = reserved, must 0 his.
- Byte 56-59 = If the Flag $100 under byte 44 present is, can here standard Inputhandle for Process indicate.
- Byte 60-63 = If the Flag $100 under byte 44 present is, can here standard Outputhandle for Process indicate.
- Byte 64-67 = If the Flag $100 under byte 44 present is, can here standard Errorhandle for Process indicate.
10.Parameter: 16 byte large Memory-Variable or structure, The Information over the launched Process aufnimmt. =>
- Byte 0-3 = the lever the Prozesses.
- Byte 4-7 = the lever the first Threads the Prozesses.
- Byte 8-11 = The ID the Prozesses.
- Byte 12-15 = The Thread-ID the Prozesses.
[/blue]
Return Value:
0 with failure, otherwise 1
Examples:
CompileMarkSeparierenDef @CreateProcess(10) !"KERNEL32","CreateProcessA"
Def @GetExitCodeProcess(2) !"KERNEL32","GetExitCodeProcess"
Def @TerminateProcess(2) !"KERNEL32","TerminateProcess"
Declare Command#,StartupInfo#,ProcessInfo#,ExitCode#
Proc CreateProcess
Parameters command$
Declare handle&
Dim Command#,Add(Len(command$),1)
Dim StartupInfo#,68
Clear startupinfo#
Long StartupInfo#,0=68
Dim ProcessInfo#,16
Clear ProcessInfo#
String Command#,0=command$
@CreateProcess(0,Command#,0,0,0,0,0,0,StartupInfo#,ProcessInfo#)
Let handle&=Long(ProcessInfo#,0)
Dispose Command#
Dispose StartupInfo#
Dispose ProcessInfo#
Return handle&
EndProc
Proc KillProcess
Parameters hprocess&
Dim exitcode#,4
@GetExitCodeProcess(hprocess&,exitcode#)
@TerminateProcess(hprocess&,@Long(exitcode#,0))
Dispose exitcode#
EndProc
Declare Terminate&,Start&,Programm$
Windowstyle 31
WindowTitle Process starten und killen
Window 0,0-640,440
Let Start&=@CreateButton(%HWND,Start,20,300,100,30)
Let Terminate&=@CreateButton(%HWND,"Terminate",200,300,100,30)
Enablewindow Terminate&,0
Enablewindow Start&,1
While 0=0
Waitinput
IF @Getfocus(Terminate&)
KillProcess @&(0)
Enablewindow Terminate&,0
Enablewindow Start&,1
ElseIF @Getfocus(Start&)
Let Programm$=@Loadfile$("Eine Anwendung auswählen:","Programme|*.EXE;*.COM;*.PIF;*.BAT")
IF Programm$<>
CreateProcess Programm$,
Enablewindow Terminate&,1
Enablewindow Start&,0
endif
'./../../function-references/xprofan/endif/'>Endif
Wend
Prozess Anwendung Programm Task starten beenden überwachen
|
|
|
| |
|
|