Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8948235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:56:10+00:00 2026-06-15T12:56:10+00:00

I use ShellExecute to do something, and the first parameters is HWND , the

  • 0

I use ShellExecute to do something, and the first parameters is HWND , the documentation on MSDN says:

A handle to the parent window used for displaying a UI or error messages. This value can be NULL if the operation is not associated with a window.

but I find whichever HWND value gets the same result.

for example :

ShellExecute(0, 'open', 'c:\', nil, nil, SW_SHOWNORMAL);

ShellExecute(Self.Handle, 'open', 'c:\', nil, nil, SW_SHOWNORMAL);

ShellExecute(123456, 'open', 'c:\', nil, nil, SW_SHOWNORMAL);

just gets the same thing (Opens disk C), so I wonder what’s the use using different HWND?

by the way, when ‘HWND = 0’ is the DeskTop’s Handle used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:56:12+00:00Added an answer on June 15, 2026 at 12:56 pm

    That HWND is used as the owner window for any UI that is shown as a result of the call to ShellExecute. For example, any error message dialogs will be owned by that window.

    The implications of a window being owned are described in the MSDN documentation. Key excerpts:

    Being owned places several constraints on a window.

    • An owned window is always above its owner in the z-order.
    • The system automatically destroys an owned window when its owner is destroyed.
    • An owned window is hidden when its owner is minimized.

    The important one is the first one. If you are calling ShellExecute from a GUI app then you want any windows to be owned by the window that is currently active in your app. So pass MyForm.Handle.

    If you have no GUI in your app then pass 0.

    In the code samples, the call to ShellExecute is not showing any UI at all. So it makes no difference what you pass. But if your calls resulted in an error dialog being shown, then the window handle that you pass would become relevant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the ShellExecute command to run an exe file which gets an input
On success, ShellExecute returns a handle. Do we need to close this handle, and
I am planning to use ShellExecute for the updater of an application written in
I use ShellExecute to open files. On a single machine among 2000+ users I
I can use the windows ShellExecute function to open a file with no problems
Can I use CreateProcess (or ShellExecute , or any other means of invoking cmd.exe
Shell Execute has the following signature : HINSTANCE ShellExecute( __in_opt HWND hwnd, __in_opt LPCTSTR
I've the below code where I use DevCon.exe to capture something and write it
I've the below code where I use DevCon.exe to capture something and write it
I have a program which crashes on the ShellExecute() instruction. If I use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.