Whenever you type an invalid executable or path with RunProgram on windows, you get a messagebox that appears "Windows cannot find '....'. Make sure you typed the name correctly, and then try again."
How can we prevent this run popping up? It halts my program until the annoying box is closed..
RunProgram - prevent messagebox from appearing?
RunProgram - prevent messagebox from appearing?
▓▓▓▓▓▒▒▒▒▒░░░░░
Re: RunProgram - prevent messagebox from appearing?
Check first if the file is there/exists before try to run anything ...


-
- Enthusiast
- Posts: 107
- Joined: Thu May 06, 2010 11:36 pm
Re: RunProgram - prevent messagebox from appearing?
Hello,
For Windows just use the CreateProcess() API.
Example:
Replace the 404.exe with C:\windows\notepad.exe and it should start Notepad.
The Documentation for CreateProcess(): http://msdn.microsoft.com/en-us/library ... 85%29.aspx
DarkPlayer
For Windows just use the CreateProcess() API.
Example:
Code: Select all
StartInfo.STARTUPINFO
StartInfo\cb = SizeOf(STARTUPINFO)
ProcessInfo.PROCESS_INFORMATION
If CreateProcess_("404.exe",0,0,0,0,0,0,0,@StartInfo, @ProcessInfo)
Debug "started"
Else
Debug "Not started :-("
If GetLastError_() = 2
Debug "File not found!"
EndIf
EndIf
The Documentation for CreateProcess(): http://msdn.microsoft.com/en-us/library ... 85%29.aspx
DarkPlayer
My blog: http://fds-team.de/cms/
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
Re: RunProgram - prevent messagebox from appearing?
>you get a messagebox that appears "Windows cannot find '....'.
You're not kidding me heh?
Is this an action made by the compiler?
You're not kidding me heh?
Is this an action made by the compiler?
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: RunProgram - prevent messagebox from appearing?
Why not just:
Code: Select all
If FileSize(path$) > 0
RunProgram([..])
EndIf
BERESHEIT
Re: RunProgram - prevent messagebox from appearing?
Thanks guys, I'm kind of "not all there" when it comes to programming. So the simplest tasks to you guys is a whole another country to me. 

▓▓▓▓▓▒▒▒▒▒░░░░░