Home > Archive > Programming with dBASE > November 2005 > Loader that launch the program









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Loader that launch the program
Roberto Portalone

2005-11-23, 7:23 am

I suppose could be a bug but I\'m not able to launch a dbase compiled application using another dbase complied application.
I attached all the zipped directory or below is the code :

Here is the simple code for the application :
// Hello world
msgbox(\"HELLO\",\"WORLD\",64)


Here is the simple code for the Loader
// Launch another program (EXE)

// using RUN
/*
nexec = \'hello.exe\'
RUN(true,nexec)
*/

// using RunWait (from dUFL)
nexec = \"Hello.exe\"
fl = new File()
fl.Open(nexec)
questa_dir = left(fl.path,len(fl.path)-len(nexec))
fl.Close()
try
if (RunWait(nexec,true,
0xFFFFFFFF,questa_di
r) == false)
msgbox(\"NO INIT\",nexec + \"NO OK\",16)
quit
endif
catch (exception e)
msgbox(\"ERROR\",nexec + \"NO OK\",16)
quit
endtry
msgbox(\"OK\",nexec + \"GO!\",64)




FUNCTION RunWait(cApp, lShow, nWait, cPath)
// Written by: Jim Sare - jimsare@yahoo.com
// Original: 11/18/1998
// Last Modified: 04/03/2003
// Changes: 04/03/2003
// Made lShow and nWait optional with appropriate defaults.
// Added optional cPath parameter.
// Eliminated dependencies on separate structure files.
// Cleaned up EXTERN prototypes.
//
// Purpose: Launch an application with ability to hide the application,
// wait a specified time or infinitely for the application\'s
// completion, and specify the application\'s working directory.
//
// Parameters: cApp: Required
// Application to execute (ie; \"NOTEPAD\").
// lShow: Optional - Default: True - Show application window
// True - Show application window
// False - Hide application window
// nWait: Optional = Default: 0 - Don\'t wait
// Number of milliseconds to wait for application to
// terminate.
// 0 - Don\'t wait
// 0xFFFFFFFF = Infinite wait
// Any value between 0 and 0xFFFFFFFF = number of
// milliseconds to
// wait.
// cPath: Optional - Default: Windows temp directory
// Application working directory.
//
// Usage: RunWait(\"NotePad\") // Run NotePad, display it, don\'t wait
// The above would be the same as:
// RunWait(\"NotePad\",; // Run NotePad
// True,; // and display it
// 0) // and don\'t wait for Notepad to end.
// RunWait(\"pkunzip -e My.ZIP\",; // Run Pkunzip
// False, // hide it
// 0xFFFFFFFF) // wait indefinitely for
// // pkunzip to end.
// // The files will be extracted
// // to the windows temp directory.
// RunWait(\"pkunzip -e My.ZIP\",; // Run Pkunzip
// False,; // hide it
// 0xFFFFFFFF,; // wait indefinitely to complete
// \"c:\\MyAppDir\") // The files will be extracted
// // to c:\\MyAppDir.
//
// NOTE:
// See the application\'s help and documentation for required
// command line option switches.
LOCAL cWorkPath, xSI, xPI, nShow, hProcess, hThread

if pCount() < 1
RETURN false
endIf
if type(\"CloseHandle\") # \"FP\"
extern CLOGICAL CloseHandle(CHANDLE)
Kernel32
endIf
if type(\"CreateProcess\") # \"FP\"
extern CLOGICAL CreateProcess(CSTRIN
G, CSTRING, CPTR, CPTR, CLOGICAL,;
CULONG, CPTR, CSTRING, CPTR, CPTR);
Kernel32 from \"CreateProcessA\"
endIf
#define CREATE_NEW_PROCESS_G
ROUP 0x00000200
#define NORMAL_PRIORITY_CLAS
S 0x00000020
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
if type(\"GetStartupInfo\") # \"FP\"
extern CVOID GetStartupInfo(CPTR)
Kernel32 from \"GetStartupInfoA\"
endIf
if type(\"GetTempPath\") # \"FP\"
extern CULONG GetTempPath(CULONG, CSTRING) Kernel32 from \"GetTempPathA\"
endIf
#define MAX_PATH 260
if type(\" WaitForSingleObject\
") # \"FP\"
extern CULONG WaitForSingleObject(
CHANDLE, CULONG) Kernel32
endIf
if pCount() < 4 // If no working directory specified, use windows temp
cWorkPath = replicate(chr(0), MAX_PATH)
GetTempPath(MAX_PATH
, cWorkPath)
else // Use specified working directory
cWorkPath = cPath
endIf
xSI = replicate(chr(0), 34) // STARTUPINFO structure
xSI.setByte(0, 68) // Set size of STARTUPINFO structure
GetStartupInfo(xSI) // Initialize STARTUPINFO with dBASE startup
xSI.setByte(48, SW_SHOWNORMAL) // Default show mode
if pCount() > 1 // Set show mode if specified with lShow
xSI.setByte(48, iIf(lShow, SW_SHOWNORMAL, SW_HIDE))
endIf
xPI = replicate(chr(0), 8) // PROCESS_INFORMATION structure
if not CreateProcess(null,;

cApp,;
null,;
null,;
false,;
bitOr(CREATE_NEW_PRO
CESS_GROUP, NORMAL_PRIORITY_CLAS
S),;
null,;
cWorkPath,;
xSI,;
xPI)
RETURN false
endIf
hProcess = Int(xPI.GetByte(0) +;
BitLShift(xPI.GetByte(1), 8) +;
BitLShift(xPI.GetByte(2), 16) +;
BitLShift(xPI.GetByte(3), 24))
hThread = Int(xPI.GetByte(4) +;
BitLShift(xPI.GetByte(5), 8) +;
BitLShift(xPI.GetByte(6), 16) +;
BitLShift(xPI.GetByte(7), 24))
WaitForSingleObject(
hProcess, iIf(pCount() > 2, nWait, 0))
CloseHandle(hProcess
)
CloseHandle(hThread)

RETURN true



Sébastien de Breuck

2005-11-29, 9:24 am

Roberto Portalone Wrote:

> I suppose could be a bug but I'm not able to launch a dbase compiled application using another dbase complied application.


I had also some problems to launch a compiled dBASE program. The solution I found was to change the current directory to the directory where the program is posted on the computer/network.

exof myy code :

The path information is stored in a table so Ican chage the directory without chaging the code

q =new query()
q.sql = [select * from "] + ugenPath + [\companies.dbf" where Company_CODE = '] + CyCode +[']
q.active = true
udfPAYROLLPATH = q.rowset.fields["PAYROLL_PATH"].value // full path
cd &udfpayrollpath
run (true, "payrollcalculation")
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com