Solved

ShellExecute ignores ShowCmd setting with IE 7

Posted on 2007-04-06
2
773 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 2012 STD Updates Issue 15 51
Edit a page at wix.com 8 49
Places to advertise 6 34
server core and windows updates 3 38
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
An article on effective troubleshooting
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

776 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