Problem with ShellExecuteEx

  • Thread starter Thread starter Todd Bethel
  • Start date Start date
T

Todd Bethel

I'm trying to use ShellExecuteEx to display file properties for a file, but I'm getting an error saying it can't find the file.

The error is very strange. It says "Windows cannot find 'xxxxx'. Make sure you typed the name correctly, and then try again." But where I have "xxxxx" here there are what appear to be Chinese characters; there are also Chinese characters in the title bar of the error. I have verified that the file really does exist.

Can anyone shed any light on this?

Here's the code:

Public Const SW_SHOW As Short = 5
Public Const SEE_MASK_INVOKEIDLIST As Short = 12

<DllImport("Shell32", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function ShellExecuteEx(ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean
End Function

Function Test

Dim sei As New SHELLEXECUTEINFO
sei.cbSize = Marshal.SizeOf(sei)
sei.lpVerb = "properties"
sei.lpFile = "c:\systeminfo.ini"
sei.nShow = SW_SHOW
sei.fMask = SEE_MASK_INVOKEIDLIST
If Not ShellExecuteEx(sei) Then
Dim ex As New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error())
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
end function


Submitted via EggHeadCafe - Software Developer Portal of Choice
Dundas Upload - Restrict Access - Complete Code
http://www.eggheadcafe.com/tutorial...f67-a488ec4d7285/dundas-upload--restrict.aspx
 
Todd said:
I'm trying to use ShellExecuteEx to display file properties for a file, but I'm getting an error saying it can't find the file.

The error is very strange. It says "Windows cannot find 'xxxxx'. Make sure you typed the name correctly, and then try again." But where I have "xxxxx" here there are what appear to be Chinese characters; there are also Chinese characters in the title bar of the error. I have verified that the file really does exist.

Can anyone shed any light on this?

Here's the code:

Public Const SW_SHOW As Short = 5
Public Const SEE_MASK_INVOKEIDLIST As Short = 12

<DllImport("Shell32", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function ShellExecuteEx(ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean
End Function

Function Test

Dim sei As New SHELLEXECUTEINFO
sei.cbSize = Marshal.SizeOf(sei)
sei.lpVerb = "properties"
sei.lpFile = "c:\systeminfo.ini"
sei.nShow = SW_SHOW
sei.fMask = SEE_MASK_INVOKEIDLIST
If Not ShellExecuteEx(sei) Then
Dim ex As New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error())
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
end function

Here it works. I've used the declaration for SHELLEXECUTEINFO from

http://www.pinvoke.net/default.aspx/shell32.shellexecuteex

Any difference to your declaration?
 
Back
Top