Advertisement
5_2007-2008 Windows API Call/ Explanation #174322

Start or Restart an exe from within your Appl.

starts an exe from within your application. But if the exe is already loaded, it becomes the focus! Normaly it starts with the poor shell-Command again and again... // IN GERMAN: Startet eine EXE aus Deiner VB-Applikation. Wenn Die EXE jedoch schon einmal gestartet wurde, wird sie lediglich fokusiert(!). Normalerweise würde sie wieder und wieder gestartet werden, wenn sie zuvor vom User nicht geschlossen wurde!

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Sub Command1_Click()
Dim Handle As Long
' the FindWindow-API needs the Caption-Name of the exe-File (e.g. Calculator for the Calc.exe!)
' Handle = FindWindow(vbNullString, "<CaptionNameOfExe>")
Handle = FindWindow(vbNullString, "Calculator") ' Is the exe already loaded?
' *! im deutschen Windows muss bei diesem Beispiel statt "Calculator" das Wort "Rechner" stehen!!!
If Handle = 0 Then ' _if the Handle becomes 0 then START the EXE-File
 Handle = Shell("CALC.EXE", 1)
 Else ' _if fires a Handle, the exe is there! Let´s focus it...
 ShowWindow Handle, 0 ' Hide the EXE (huh! Where is the exe???)
 ShowWindow Handle, 1 ' Show the EXE (now it becomes the Focus!!!)
End If
End Sub
Original Comments (3)
Recovered from Wayback Machine