Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateProcess parameters

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi!

The following code is from a VFP application where variable lcProgram would be "C:\executable.exe path\filename.ext"

Control is passed to "C:\executable.exe path\filename.ext" and control returns to the VFP application on termination.

Could someone advise where and how to modify the code so that "C:\executable.exe path\filename.ext" will run hidden and not in a minimised, normal or maximised state?

lcOriginal = ALLTRIM(SHEETS.filename) && Original ALLTRIM(filename)
COPY FILE (lcOriginal) TO C:\windows\temp\temp.jpg && Copy file to temp file
lcFile = ALLTRIM(SHEETS.filename) && Original ALLTRIM(filename)
lcProgram = ALLT(USER.editor);
[tab]+[ "];
[tab]+ALLT(SHEETS.filename) ;
[tab]+["] && Define lcProgram

#DEFINE NORMAL_PRIORITY_CLASS 32
#DEFINE IDLE_PRIORITY_CLASS 64
#DEFINE HIGH_PRIORITY_CLASS 128
#DEFINE REALTIME_PRIORITY_CLASS 1600
#DEFINE WAIT_TIMEOUT 0x00000102
#DEFINE WAIT_INTERVAL 200

DECLARE INTEGER CreateProcess IN kernel32.DLL ;
[tab]INTEGER lpApplicationName,;
[tab]STRING lpCommandLine,;
[tab]INTEGER lpProcessAttributes,;
[tab]INTEGER lpThreadAttributes,;
[tab]INTEGER bInheritHandles,;
[tab]INTEGER dwCreationFlags,;
[tab]INTEGER lpEnvironment,;
[tab]INTEGER lpCurrentDirectory,;
[tab]STRING @lpStartupInfo,;
[tab]STRING @lpProcessInformation

DECLARE INTEGER WaitForSingleObject IN kernel32.DLL ;
[tab]INTEGER hHandle, INTEGER dwMilliseconds

DECLARE INTEGER CloseHandle IN kernel32.DLL ;
[tab]INTEGER hObject

DECLARE INTEGER GetLastError IN kernel32.DLL

start = long2str(68) + REPLICATE(CHR(0), 64)
process_info = REPLICATE(CHR(0), 16)

File2Run = (lcProgram) + CHR(0)
RetCode = CreateProcess(0, File2Run, 0, 0, 1, ;
[tab]NORMAL_PRIORITY_CLASS, 0, 0, @start, @process_info)

IF RetCode = 0
[tab]=MESSAGEBOX("Error occurred. Error code: ", GetLastError())
[tab]RETURN
ENDIF

hProcess = str2long(SUBSTR(process_info, 1, 4))

DO WHILE .T.
[tab]IF WaitForSingleObject(hProcess, WAIT_INTERVAL) != WAIT_TIMEOUT
[tab][tab]EXIT
[tab]ELSE
[tab][tab]DOEVENTS
[tab]ENDIF
ENDDO

RetCode = CloseHandle(hProcess)

TIA

Chris :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top