我使用以下 VB.net (Framework 4) 代码打开文件属性。
当目标设置为 x86 时,这可以正常工作。
<StructLayout(LayoutKind.Sequential)> _
Public Structure SHELLEXECUTEINFO
Public cbSize As Integer
Public fMask As UInteger
Public hwnd As IntPtr
Public lpVerb As [String]
Public lpFile As [String]
Public lpParameters As [String]
Public lpDirectory As [String]
Public nShow As Integer
Public hInstApp As Integer
Public lpIDList As Integer
Public lpClass As [String]
Public hkeyClass As Integer
Public dwHotKey As UInteger
Public hIcon As Integer
Public hProcess As Integer
End Structure
Private Const SW_SHOW As Integer = 5
Private Const SEE_MASK_INVOKEIDLIST As UInteger = 12 ' 0x0000000C
<DllImport("shell32.dll")> _
Private Shared Function ShellExecuteEx(ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean
End Function
Public Shared Sub ShowProperties(ByVal path As String)
Dim fi As New IO.FileInfo(path)
Dim info As New SHELLEXECUTEINFO()
info.cbSize = Marshal.SizeOf(info)
info.lpVerb = "properties"
info.lpFile = fi.Name
info.lpDirectory = fi.DirectoryName
info.nShow = SW_SHOW
info.fMask = SEE_MASK_INVOKEIDLIST
ShellExecuteEx(info)
End Sub
现在我的项目需要 x64 目标,上面的代码不再起作用。:(
GetLastError
返回 0 并且没有异常或错误消息。
我搜索了两天并尝试了一些东西,但我没有找到解决方案。这里有什么想法吗?
感谢帮助!