Solved

ShellExecute ignores ShowCmd setting with IE 7

Posted on 2007-04-06
2
770 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:purplesoup
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
When you pass the text file, it will open with notepad, which will obey the window sizes.  I have a feeling (but I've never tried / confirmed it) that Windows explorer may behave differently, and when you send a URL, Windows Explorer handles the request, and changes itself to IE.  When you use ShellExecute, try explicity executing Inernet Explorer, passing a URL:
iexplore.exe "http://url.com/"

Rob.
0
 

Author Comment

by:purplesoup
Comment Utility
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!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now