Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Folks,

I want to open explorer.exe on my control panel.
I've succeeded for many other programs, like notepad, calc.exe, ... but when i try with explorer, an external windows explorer appears.

Here's my code, some help please :

VB
Imports System.Runtime.InteropServices

Private Const SWM_COMMAND As Integer = 274
Private Const SC_MAXIMIZE As Integer = 61488
Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal Iparam As Integer) As Integer

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim Proc = Process.Start("explorer")
    Proc.WaitForInputIdle()
    SetParent(Proc.MainWindowHandle, Me.Panel1.Handle)
    SendMessage(Proc.MainWindowHandle, SWM_COMMAND, SC_MAXIMIZE, 0)
End Sub
Posted
Updated 22-Dec-11 3:13am
v2

This is expected behavior.

Please understand that "Explorer" is a separate process, and the processes are well isolated. Even if you manage to stick its window into your form (this is possible in principle, but should be avoided by all means), you won't be able to integrate it functionally anyway.

If you want to browse file system in your form, create such a browser, which will takes some hard work, but not conceptually very difficult. Or use one of the dialog classes shown here: http://msdn.microsoft.com/en-us/library/system.windows.forms.commondialog.aspx[^].

—SA
 
Share this answer
 
v2
Comments
Monjurul Habib 23-Dec-11 15:36pm    
nice answer, 5!
Sergey Alexandrovich Kryukov 23-Dec-11 15:39pm    
Thank you, Monjurul.
--SA
The following example first spawns an instance of Internet Explorer and displays the contents of the Favorites folder in the browser. It then starts some other instances of Internet Explorer and displays some specific pages or sites. Finally it starts Internet Explorer with the window being minimized while navigating to a specific site.

Try the following link:
Process.Start Method (String)
 
Share this answer
 
you can try it

//it's open Control Panel
Process.Start ( "control.exe" );

//it's open my computer
Process.Start ( "explorer.exe" );

//it's open Internet Explorer
Process.Start ( "iexplore.exe" );
 
Share this answer
 
v2
Comments
contact97438 22-Dec-11 9:50am    
Yes, i know, but for Explorer.exe, it's an external windows, out of my main form1, where i've put a panel control.
Sergey Alexandrovich Kryukov 22-Dec-11 13:02pm    
So what? Did you expect something else. Please see my answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900