Error With Tsystem1.exe
me to start an external application and waitfor it to exit before continuing on. In using a function I found, itworks great if using an application such as notePad. However, withan application I need to start, it returns immediately, thus throwingthe process out of whack of my application.Here's the function I've been trying to use:function WinExecAndWait32(Path: PChar; Visibility: Word; Timeout :DWORD): integer;varWaitResult : integer;StartupInfo: TStartupInfo;ProcessInfo: TProcessInformation;iResult : integer;beginFillChar(StartupInfo, SizeOf(TStartupInfo), 0);with StartupInfo dobegincb := SizeOf(TStartupInfo);dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;{ you could pass sw_show or sw_hide as parameter: }wShowWindow := visibility;end;if CreateProcess(nil,path,nil, nil, False, NORMAL_PRIORITY_CLASS,nil, nil, StartupInfo, ProcessInfo) thenbeginWaitResult := WaitForSingleObject(ProcessInfo.hProcess, timeout);{ timeout is in miliseconds or INFINITE if you want to waitforever }result := WaitResult;endelse{ error occurs during CreateProcess see help for details }result:=GetLastError;CloseHandle(ProcessInfo.hProcess);CloseHandle(ProcessInfo.hThread);end;And here's how I'm calling the application:WinExecAndWait32(PChar(self.ClientMainDir + 'cswin.exe'),SW_NORMAL, INFINITE);Does anybody know why this is returning immediately???? As I'vestated, things such as notepad works, so perhaps it's the applicationbeing called.... Godwin Stewart 2002-08-15 21:07:17 UTC PermalinkRaw Message On Thu, 15 Aug 2002 20:56:36 -0000, "wizaerd"Post by wizaerdDoes anybody know why this is returning immediately???? As I'vestated, things such as notepad works, so perhaps it's the applicationbeing called....What application are you invoking with CreateProcess?It could well be that the application you're invoking simply invokes anotherapplication and exits immediately.--Duct tape is like the Force. It has a light side anda dark side, and it holds the universe together.____________________________________________| G. Stewart -- ***@sgms-centre.com || ***@spamcop.net ||--------------------------------------------|| Linux User
(executable files) and service code errors. Our goal is to eliminate these problems and they headaches they cause for PC users. Most of the time, it's difficult to understand the error messages that pop up on your screen when you experience an application EXE error. It could be the software application itself, an internal Windows® problem (possibly a registry issue or corrupt device driver) or an actual PC hardware device such as http://delphi-programming.yahoogroups.narkive.com/3ElcFNj1/waitforsingleobject-not-waiting faulty RAM or a failing hard drive. EXE Files Explained… .EXE is the file name extension referencing an executable file (i.e. a software program) in Windows® operating system. These files run your programs and also contain other embedded resources such as bit maps, windows icons, etc. which the software might call and use for it's http://windows-exe-errors.com/ user interface, or better known as a GUI. So What Exactly Causes EXE Errors? There are multiple reasons why running an EXE file could cause your program to crash: Malicious Software: Direct PC infections such as computer viruses, backdoor trojans, malware, keyloggers and spyware. These programs are usually installed without the users content (or knowledge) through either different websites on the Internet or as email attachments. If executed, they attempt to take control or modify important registry entries or .EXE files critical for your PC operating system to function properly. Application Conflicts: Running multiple software applications that are conflicting with one another. Incomplete Installation: While attempting to launch a setup.exe or install.exe file, the software installer locks up, looses connection (if installing through a web browser), or crash during install. This can cause corrupt registry entries and trigger EXE errors. Missing or Corrupt Device Drivers: All your computer hardware devices use a small software file known as a device driver (or .INF)
I did however, figure it out and it now works as I expect it too... Thanx for the help!!! --- In delphi-programming@xxxx, "Stephen Wood"