Solved

ShellExecute ignores ShowCmd setting with IE 7

Posted on 2007-04-06
2
774 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
ID: 18915880
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
ID: 18917406
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

829 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