Results 1 to 2 of 2

Thread: [RESOLVED] Shell - Show Properties

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Resolved [RESOLVED] Shell - Show Properties

    I know a couple of these threads exist on the internet, but none describe what I am having...

    vb Code:
    1. Public Structure SHELLEXECUTEINFO
    2.         Public cbSize As Integer
    3.         Public fMask As Integer
    4.         Public hwnd As IntPtr
    5.         <MarshalAs(UnmanagedType.LPTStr)> Public lpVerb As String
    6.         <MarshalAs(UnmanagedType.LPTStr)> Public lpFile As String
    7.         <MarshalAs(UnmanagedType.LPTStr)> Public lpParameters As String
    8.         <MarshalAs(UnmanagedType.LPTStr)> Public lpDirectory As String
    9.         Dim nShow As Integer
    10.         Dim hInstApp As IntPtr
    11.         Dim lpIDList As IntPtr
    12.         <MarshalAs(UnmanagedType.LPTStr)> Public lpClass As String
    13.         Public hkeyClass As IntPtr
    14.         Public dwHotKey As Integer
    15.         Public hIcon As IntPtr
    16.         Public hProcess As IntPtr
    17.     End Structure
    18.     Private Const SEE_MASK_INVOKEIDLIST = &HC
    19.     Private Const SEE_MASK_NOCLOSEPROCESS = &H40
    20.     Private Const SEE_MASK_FLAG_NO_UI = &H400
    21.     Private Const SW_SHOW As Integer = 5
    22.     Private Declare Function ShellExecuteEx Lib "shell32.dll" Alias "ShellExecuteExA" (ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean
    23.     Public Function ShowProps(ByVal FileName As String, ByVal OwnerhWnd As IntPtr) As Boolean
    24.         Dim sei As New SHELLEXECUTEINFO
    25.         sei.cbSize = Marshal.SizeOf(sei)
    26.         sei.fMask = SEE_MASK_INVOKEIDLIST
    27.         sei.hwnd = OwnerhWnd
    28.         sei.lpVerb = "properties"
    29.         sei.lpFile = FileName
    30.         sei.lpParameters = vbNullChar
    31.         sei.lpDirectory = vbNullChar
    32.         sei.nShow = SW_SHOW
    33.         sei.hInstApp = 0
    34.         sei.lpIDList = 0
    35.         Return ShellExecuteEx(sei)
    36.     End Function

    (import Marshal btw)

    When I first ran the code, it worked. But after some days (now) it suddenly stopped working, and only displays an error with, for example:
    "Windows cannon find 'C'. Make sure you type the name correctly, and then try again.
    This, while I send the request for the file of "C:\test.txt". It only seems to read the first character. What is going on here?

    (Running on Window 7)

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Shell - Show Properties

    Well got it figured out by now. For those interested, I now use this structure:
    Code:
        Public Structure SHELLEXECUTEINFO
            Sub New(ByVal Verb As String)
                Me.lpVerb = Verb
                Me.cbSize = Runtime.InteropServices.Marshal.SizeOf(Me)
            End Sub
            Private cbSize As Integer
            Public fMask As Mask
            Public hwnd As IntPtr
            Public lpVerb As String
            Public lpFile As String
            Public lpParameters As String
            Public lpDirectory As String
            Public nShow As SW
            Public hInstApp As IntPtr
            Public lpIDList As IntPtr
            Public lpClass As String
            Public hkeyClass As IntPtr
            Public dwHotKey As Integer
            Public hIcon As IntPtr
            Public hProcess As IntPtr
    
            Public Enum Mask As Integer
                NONE = &H0
                CLASSNAME = &H1
                CLASSKEY = &H3
                IDLIST = &H4
                INVOKEIDLIST = &HC
                ICON = &H10
                HOTKEY = &H20
                NOCLOSEPROCESS = &H40
                CONNECTNETDRV = &H80
                NOASYNC = &H100
                DOENVSUBST = &H200
                FLAG_NO_UI = &H400
                UNICODE = &H4000
                NO_CONSOLE = &H8000
                ASYNCOK = &H100000
                NOQUERYCLASSSTORE = &H1000000
                HMONITOR = &H200000
                NOZONECHECKS = &H800000
                WAITFORINPUTIDLE = &H2000000
                FLAG_LOG_USAGE = &H4000000
            End Enum
            Public Enum SW As Integer
                ''' <summary>
                ''' No SW command, default value.
                ''' </summary>
                NONE
                ''' <summary>
                ''' Hides the window and activates another window.
                ''' </summary>
                HIDE
                ''' <summary>
                ''' Maximizes the specified window.
                ''' </summary>
                MAXIMIZE
                ''' <summary>
                ''' Minimizes the specified window and activates the next top-level window in the z-order.
                ''' </summary>
                MINIMIZE
                ''' <summary>
                ''' Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. 
                ''' An application should specify this flag when restoring a minimized window.
                ''' </summary>
                RESTORE
                ''' <summary>
                ''' Activates the window and displays it in its current size and position.
                ''' </summary>
                SHOW
                ''' <summary>
                ''' Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. 
                ''' An application should call ShowWindow with this flag to set the initial show state of its main window.
                ''' </summary>
                SHOWDEFAULT
                ''' <summary>
                ''' Activates the window and displays it as a maximized window.
                ''' </summary>
                SHOWMAXIMIZED
                ''' <summary>
                ''' Activates the window and displays it as a minimized window.
                ''' </summary>
                SHOWMINIMIZED
                ''' <summary>
                ''' Displays the window as a minimized window. The active window remains active.
                ''' </summary>
                SHOWMINNOACTIVE
                ''' <summary>
                ''' Displays the window in its current state. The active window remains active.
                ''' </summary>
                SHOWNA
                ''' <summary>
                ''' Displays a window in its most recent size and position. The active window remains active.
                ''' </summary>
                SHOWNOACTIVATE
                ''' <summary>
                ''' Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position.
                ''' An application should specify this flag when displaying the window for the first time.
                ''' </summary>
                SHOWNORMAL
            End Enum
        End Structure

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