Code : Tout sélectionner
#Commande="Google.com"
OpenWindow(0, 0, 0, 640, 480, "---", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
EditorGadget(0, 10, 10, 620, 460)
SetGadgetFont(0,LoadFont(0,"Courier",8))
Procedure Lancement()
Handle = RunProgram("nslookup","","", #PB_Program_Hide|#PB_Program_Connect|#PB_Program_Open|#PB_Program_Write|#PB_Program_Read)
If Handle
While ProgramRunning(Handle)
Delay(10)
TailleRecu=AvailableProgramOutput(Handle)
If TailleRecu
AddGadgetItem(0, -1, "###### Taille reçue "+Str(TailleRecu))
*Tampon=AllocateMemory(TailleRecu)
ReadProgramData(Handle,*Tampon,TailleRecu)
AddGadgetItem(0, -1, PeekS(*Tampon,TailleRecu))
If FindString(PeekS(*Tampon,TailleRecu),">",1)
TailleEnvoie=WriteProgramStringN(Handle,#Commande)
AddGadgetItem(0, -1, "###### Envoie de la commande : "+#Commande+" ("+Str(TailleEnvoie)+" caractère)")
CloseProgram(Handle)
ProcedureReturn
EndIf
FreeMemory(*Tampon)
EndIf
Wend
CloseProgram(Handle)
EndIf
AddGadgetItem(0, -1, "Fin normale")
EndProcedure
CreateThread(@Lancement(),0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow