What is ShellExecute private declare for?
Anyonne can tell me how to use it?
VB Code:
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
Re: What is ShellExecute private declare for?
Private vs Public is only for the scope of the function throughout your project.
Code:
Option Explicit
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_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", "C:\Users\Public\Test1.txt", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Re: What is ShellExecute private declare for?
So this is almost same with
Just with more functions thanks
Re: What is ShellExecute private declare for?
Yes and no. Shell will run a exe or other executable program but it will not run / open a file with its associated program like ShellExecute does.
If you were to shell a txt file it will error but if you were to ShellExecute the same txt file it wil run notepad/wordpad and open the txt file in it.
Errors:
Shell "C:\Something.txt"
Will not error:
ShellExecute Me.hwnd, "open", "C:\Something.txt", vbNullString, "C:\", SW_SHOWNORMAL