Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Run command long file name
Message
 
À
24/08/2006 14:54:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Divers
Thread ID:
01148006
Message ID:
01148414
Vues:
17
Tracy,
This is great! Thanks so much! By the way, is there some reason why you choose
to use create process vs other methods such as WinExec.
On http://www.news2news.com/vfp/?group=58&function=2, they write:

"The WinExec function runs the specified application. Note This function
is provided only for compatibility with 16-bit Windows.
Win32-based applications should use the CreateProcess function"

So it looks like CreateProcess is a newer improved something?

Steve
m1 = "c:\program files\newbie\newbie.exe" 
m2 = " /login admin /password asdfasdf" 
m2b = " /exec ie"
m3 = " /script c:\d\bull\americanbulls.nbl"
m4 = " /autoclose true" 
m5 = " /hidescripts true"
m6 = (m1) + (m2) + m3 + m4 + m5
myCommand = m6

*m.lcApp = 'NotePad.Exe'
m.lcApp = myCommand
*m.lcCmdLine = ' myfile.txt '
*lcdir = 'c:\windows\'
lcdir = 'c:\d\bull\'

DO DECLPROCS
#DEFINE INFINITE  0xFFFFFFFF
LOCAL lcStartupInfo, lcProcInfo, hProcess, ;
	lnPrio, lnIBelieve1
lnIBelieve1 = 1  
lnPrio = 32 
lcStartupInfo = CHR(68) + REPLI(CHR(0), 67)
lcProcInfo = REPLI(CHR(0), 16)
&&IF CreateProcess(0, m.lcApp+" "+m.lcCmdLine+CHR(0), 0,0,; &&
IF CreateProcess(0, m.lcApp+" "+CHR(0), 0,0,;
		m.lnIBelieve1, m.lnPrio,;
		0, 0, @lcStartupInfo, @lcProcInfo) <> 0
	hProcess = buf2dword(SUBSTR(lcProcInfo, 1,4))
	hThread = buf2dword(SUBSTR(lcProcInfo, 5,4))
	= WaitForSingleObject(hProcess, INFINITE)
	= CloseHandle(hThread)
	= CloseHandle(hProcess)
ELSE
	RETURN .F.
ENDIF
WAIT WINDOW "Press Anykey to return to VFP."
RETURN

PROCEDURE DECLPROCS
DECLARE INTEGER CreateProcess IN kernel32;
	INTEGER lpAppName, STRING lpCmdLine, INTEGER lpProcAttr,;
	INTEGER lpThrAttr, INTEGER bInhHandles, INTEGER dwCrFlags,;
	INTEGER lpEnvir, INTEGER lpCurDir, ;
	STRING @lpStInfo, STRING @lpProcInfo
DECLARE INTEGER GetLastError IN kernel32
DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
DECLARE INTEGER WaitForSingleObject IN kernel32;
	INTEGER hHandle, INTEGER dwMilliseconds
RETURN

FUNCTION buf2dword(lcBuffer)
RETURN ASC(SUBSTR(lcBuffer, 1,1)) + ;
	ASC(SUBSTR(lcBuffer, 2,1)) * 256 +;
	ASC(SUBSTR(lcBuffer, 3,1)) * 65536 +;
	ASC(SUBSTR(lcBuffer, 4,1)) * 16777216
RETURN
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform