Link to home
Start Free TrialLog in
Avatar of purplesoup
purplesoupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ShellExecute ignores ShowCmd setting with IE 7

I am using ShellExecute to launch a browser in a web page, however it appears to totally ignore the nShowCmd parameter. Below are the declarations I am using:

If I pass another file - for example a text file - then the parameter is obeyed - minimize, hide etc - but if I pass a URL the browser always displays full screen with focus. I want to start the browser either minimized or hidden - Does anyone know how to get this to work?

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
     
Public Enum EShellShowConstants
    essSW_HIDE = 0
    essSW_MAXIMIZE = 3
    essSW_MINIMIZE = 6
    essSW_SHOWMAXIMIZED = 3
    essSW_SHOWMINIMIZED = 2
    essSW_SHOWNORMAL = 1
    essSW_SHOWNOACTIVATE = 4
    essSW_SHOWNA = 8
    essSW_SHOWMINNOACTIVE = 7
    essSW_SHOWDEFAULT = 10
    essSW_RESTORE = 9
    essSW_SHOW = 5
End Enum
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of purplesoup

ASKER

Interestingly it doesn't seem to mind if you pass "iexplore.exe" or just "explorer", but ShellExecute wants something passed as the lpFile parameter when you pass a URL, otherwise the nShowCmd option just appears to be ignored.

Thanks for your help - that solves the problem!