Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with ShellExecuteEx

0 views
Skip to first unread message

toddbethel

unread,
Dec 20, 2009, 3:48:30 PM12/20/09
to
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/tutorials/aspnet/273af48b-e5f4-48f4-8f67-a488ec4d7285/dundas-upload--restrict.aspx

Armin Zingler

unread,
Dec 20, 2009, 7:29:16 PM12/20/09
to
Todd Bethel schrieb:

> 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?


--
Armin

Todd

unread,
Dec 28, 2009, 7:59:01 PM12/28/09
to
That fixed it. Thanks.

"Armin Zingler" wrote:

> .
>

0 new messages