Results 1 to 2 of 2

Thread: Folder Menu Items

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    1

    Exclamation

    I'm trying to figure out how, from VB to get a folder's menu options. I'm trying to simulate a right click on the folder and be able to select one of the menu items that would show up there. I'm 90% sure I have to use API's but have no idea where to start. Help help help. Even a point to the right API calls would be useful.
    Thanks

  2. #2
    Member
    Join Date
    Oct 2000
    Location
    Netherlands
    Posts
    54

    Smile Use Properties?

    I assume you mean teh properties form of a folder? Just use this for any properties form you want to pop up. It;s from VB net, it also works with folders:

    Using using this simple routine, the SHELLEXECUTEINFO type structure and the ShellExecuteEx() API, 32 bit Visual Basic applications can display the file property page for any passed file on Windows 95, 98 or NT4. As long as the path to the file is known, this routine can be invoked. It works for both registered and unregistered Windows file types, as well as bringing up the DOS property sheet for DOS applications or files (try pointing the app to autoexec.bat).

    Code:
    Option Explicit
    
    Type SHELLEXECUTEINFO
        cbSize        As Long
        fMask         As Long
        hwnd          As Long
        lpVerb        As String
        lpFile        As String
        lpParameters  As String
        lpDirectory   As String
        nShow         As Long
        hInstApp      As Long
        lpIDList      As Long     'Optional parameter
        lpClass       As String   'Optional parameter
        hkeyClass     As Long     'Optional parameter
        dwHotKey      As Long     'Optional parameter
        hIcon         As Long     'Optional parameter
        hProcess      As Long     'Optional parameter
    End Type
    
    Public Const SEE_MASK_INVOKEIDLIST = &HC
    Public Const SEE_MASK_NOCLOSEPROCESS = &H40
    Public Const SEE_MASK_FLAG_NO_UI = &H400
    
    Declare Function ShellExecuteEX _
       Lib "shell32.dll" Alias "ShellExecuteEx" _
      (SEI As SHELLEXECUTEINFO) As Long

    Form Code

    To a project form add two command buttons (cmdProperties and cmdEnd) and a text box (Text1). Add the following to the form:

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
       Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
      
    End Sub
    
    
    Private Sub cmdEnd_Click()
       
       Unload Me
       
    End Sub
    
    
    Public Sub ShowProperties(filename As String, OwnerhWnd As Long)
     
      'open a file properties property page for 
      'specified file if return value
    
       Dim SEI As SHELLEXECUTEINFO
       Dim r As Long
     
      'Fill in the SHELLEXECUTEINFO structure 
       With SEI
          .cbSize = Len(SEI)
          .fMask = SEE_MASK_NOCLOSEPROCESS Or _
                   SEE_MASK_INVOKEIDLIST Or _
                   SEE_MASK_FLAG_NO_UI
          .hwnd = OwnerhWnd
          .lpVerb = "properties"
          .lpFile = filename
          .lpParameters = vbNullChar
          .lpDirectory = vbNullChar
          .nShow = 0
          .hInstApp = 0
          .lpIDList = 0
       End With
     
      'call the API to display the property sheet 
       r = ShellExecuteEX(SEI)
      
    End Sub
    
    
    Private Sub cmdProperties_Click()
    
       Dim fname As String
     
      'get the path/filename from Text1 
       fname = (Text1)
     
      'show the properties dialog, passing the filename
      'and the owner of the dialog  
       Call ShowProperties(fname, Me.hwnd) 
    
    End Sub

    A mind is like a parachute, it has to open to let it work
    www.2beesoft.com for Icon Manager with over 20.000 free icons
    VB6 Ent. SP4, ASP, W2000/W98

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width