Problem with ShellExecuteEx

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
 
A

Armin Zingler

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top