API: ShellExecute
- Je kan een programma opstarten met Shell door
t = Shell(EXEnaam)
- Maar bestanden zijn gelinkt aan applicaties. Om bestand op te starten met gelinkte
applicatie bestaat er een API ShellExecute.
- De declaratie ziet er als volgt uit:
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile
As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long Private
Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
- Wat willen deze parameters zeggen? Dit vind je in de MSKB
documentatie:
hwnd - hwnd of calling form. Can be Screen.ActiveForm
lpOperation - Action verb from the context menu ("Open", "Print",
etc.) '
lpFile - path+Filename to Open, print , whatever.
If lpFile is not an exe, the associated program (if any) ' will be used to perform the
action.
lpParameters - additional command line parameters
lpDirectory - Startup directory
nShowCmd - Initial window state (One of the SW_ constants)
De terugkeerwaarde is groter dan 32 als het gelukt is.
- Om deze functie te gebruiken doe je het volgende:
Dim mijnbestand As String
mijnbestand = ...
Dim lRet As Long
lRet = ShellExecute(0&, vbNullString, mijnbestand, vbNullString, vbNullString,
SW_NORMAL)
[VB Web] - [hlrnet] - [copyright]