I am trying to run;
Environ$("SystemRoot") + "\system32\inetcpl.cpl"
(C:\WINDOWS\system32\inetcpl.cpl)
and
Environ$("SystemRoot") + "\system32\firewall.cpl"
(C:\WINDOWS\system32\firewall.cpl)
I can't use following code as the files end with .cpl and not .exe
Code:
P 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 Sub com_Button_Click()
Call ShellExecute(hWnd, "open", Environ$("SystemRoot") + "\system32\inetcpl.cpl", "", vbNullString, vbNormalFocus)
End Sub
ShellExecute returns 31 and not 33.
I can't even run a shortcut file to load/run inetcpl.cpl as a shortcut file ends with .lnk
ShellExecute(hWnd, "edit"
ShellExecute(hWnd, "explore"
ShellExecute(hWnd, "run"
ShellExecute(hWnd, "exec"
Etc. also don't work.
Help!
Don't spend too much time on your computer.
Sit on a chair instead!!
It's a lot more comfortable and better for your hardware. :-/
ShellExecute() opens the default program (only if it is set)
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_SHOWMINIMIZE As Long = 2
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWNOACTIVATE As Long = 4
Private Const SW_SHOW As Long = 5
Private Const SW_MINIMIZE As Long = 6
Private Const SW_SHOWMINNOACTIVED As Long = 7
Private Const SW_SHOWNA As Long = 8
Private Const SW_RESTORE As Long = 9
Private Const SW_SHOWDEFAULT As Long = 10
'SW_HIDE 0
'Hides the window and activates another window.
'SW_MAXIMIZE 3
'Maximizes the specified window.
'SW_MINIMIZE 6
'Minimizes the specified window and activates
'the next top-level window in the Z order.
'SW_RESTORE 9
'Activates and displays the window. If the window
'is minimized or maximized, Windows restores it
' to its original size and position. An application
'should specify this flag when restoring a minimized window.
'SW_SHOW 5
'Activates the window and displays it in its current size and position.
'SW_SHOWDEFAULT 10
'Sets the show state based on the SW_ flag
' specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
'SW_SHOWMAXIMIZED 3
'Activates the window and displays it as a maximized window.
'SW_SHOWMINIMIZE 2
'Activates the window and displays it as a minimized window.
'SW_SHOWMINNOACTIVED 7
'Displays the window as a minimized window. The active window remains active.
'SW_SHOWNA 8
'Displays the window in its current state. The active window remains active.
'SW_SHOWNOACTIVATE 4
'Displays a window in its most recent size
'and position. The active window remains active.
'SW_SHOWNORMAL 1
'Activates and displays a window. If the window is minimized or
'maximized, Windows restores it to its original size and position.
'An application should specify this flag when displaying the window
'for the first time
Private Sub Command1_Click()
ShellExecute 0&, "OPEN", "www.msn.com", vbNullString, "C:\", SW_SHOWMINIMIZE
' ShellExecute 0&, "OPEN", "D:\temp\pps-cd\play.bat", vbNullString, "C:\", SW_SHOWNORMAL
' ShellExecute 0&, "OPEN", "outlook.exe", vbNullString, "C:\", SW_SHOWNORMAL
' ShellExecute 0&, "PRINT", "D:\temp\jazz.txt", vbNullString, "D:\temp", SW_SHOWMINIMIZE
Beep
' c:\program files\outlook express\msimn.exe
' c:\ = Destination Folder
End Sub
SHELL() might help:
Code:
Option Explicit
Private Sub Form_Load()
Shell ("C:\Windows\System32\cmd.exe /c " & _
"C:\Windows\System32\ipconfig >> d:\myip.txt"), vbNormalFocus
End Sub
What you should do is make use of the Shell object to run rundll32.exe which runs shell32.dll which can run all these control panel applets. For example :
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.