|
-
Mar 15th, 2011, 09:52 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Shell - Show Properties
I know a couple of these threads exist on the internet, but none describe what I am having...
vb Code:
Public Structure SHELLEXECUTEINFO
Public cbSize As Integer
Public fMask As Integer
Public hwnd As IntPtr
<MarshalAs(UnmanagedType.LPTStr)> Public lpVerb As String
<MarshalAs(UnmanagedType.LPTStr)> Public lpFile As String
<MarshalAs(UnmanagedType.LPTStr)> Public lpParameters As String
<MarshalAs(UnmanagedType.LPTStr)> Public lpDirectory As String
Dim nShow As Integer
Dim hInstApp As IntPtr
Dim lpIDList As IntPtr
<MarshalAs(UnmanagedType.LPTStr)> Public lpClass As String
Public hkeyClass As IntPtr
Public dwHotKey As Integer
Public hIcon As IntPtr
Public hProcess As IntPtr
End Structure
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Const SW_SHOW As Integer = 5
Private Declare Function ShellExecuteEx Lib "shell32.dll" Alias "ShellExecuteExA" (ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean
Public Function ShowProps(ByVal FileName As String, ByVal OwnerhWnd As IntPtr) As Boolean
Dim sei As New SHELLEXECUTEINFO
sei.cbSize = Marshal.SizeOf(sei)
sei.fMask = SEE_MASK_INVOKEIDLIST
sei.hwnd = OwnerhWnd
sei.lpVerb = "properties"
sei.lpFile = FileName
sei.lpParameters = vbNullChar
sei.lpDirectory = vbNullChar
sei.nShow = SW_SHOW
sei.hInstApp = 0
sei.lpIDList = 0
Return ShellExecuteEx(sei)
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)
-
Mar 20th, 2011, 11:16 AM
#2
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|