Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a exe from within VFP with parameters
Message
De
19/02/2017 14:17:44
 
 
À
19/02/2017 11:26:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012 R2
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Divers
Thread ID:
01648061
Message ID:
01648146
Vues:
63
Then i recquire another testers in this place !
Advice to fans to test !

this is the code i tested on my machine
*activex must be register before using this code with regasm
*run cmd as administrator and issue: (correct the path of cbUtilities)
*C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe C:\Users\yousfi\Downloads\cbUtilities_activeX_cetin\cbUtilities.dll /codebase

*behavior: when the notepad fires on desktop closing it manually causes the vfp9 crashing (on many diffrent  tests) !
*OS=windows 10 pro.

clea all
set defa to "C:\Users\yousfi\Downloads\cbUtilities_activeX_cetin"   &&correct your path here

Local o As "cbNetCOM.Utilities", eh As 'cbUtilityEvents'
o = Createobject("cbNetCOM.Utilities")

Local lcFileName
m.lcFileName = 'seTest.txt'
Strtofile('',m.lcFileName)

eh=Createobject("cbUtilityEvents",m.o)
Eventhandler(m.o, m.eh)

o.ShellExecProcess("notepad.exe", m.lcFileName, .F., .F.)

* Shellexecuted the process
* Lets do some work while it is running
* Just to demonstrate it is async and we get the event 
* when it exists
Public oTimer as Timer
oTimer = CreateObject('myTimer')
m.oTimer.Enabled = .t.

Define Class myTimer as Timer
  Interval = 5000 && every 5 seconds
  Procedure Timer
   wait window  'I am doing nothing useful, just hanging around. '+ttoc( Datetime())  nowait
  endproc
enddefine

Define Class cbUtilityEvents As Session OlePublic
	Implements IcbEvents In "CBUTILITIES.TLB"    &&in the source zip folder
	oHook = Null

	Procedure Init(toHook)
		This.oHook = m.toHook
	Endproc

	Procedure IcbEvents_OnProcessExit(ExitCode As Number, exitTime As Date, exceptionMessage As String) As VOID
		If Empty(m.exceptionMessage)
			wait window  'Process has exited on '+trans( m.exitTime)+ ' with exit code '+trans(m.ExitCode)
			MessageBox(FileToStr('seTest.txt'))
		Else
			wait window  'Process had and exception. Message:'+trans( m.exceptionMessage)
		Endif
		Eventhandler(This.oHook,This,.T.)
		This.oHook = Null
	Endproc
Enddefine
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform