本文整理汇总了VB.NET中System.Runtime.InteropServices.DllImportAttribute.PreserveSig字段的典型用法代码示例。如果您正苦于以下问题:VB.NET DllImportAttribute.PreserveSig字段的具体用法?VB.NET DllImportAttribute.PreserveSig怎么用?VB.NET DllImportAttribute.PreserveSig使用的例子?那么恭喜您, 这里精选的字段代码示例或许可以为您提供帮助。您也可以进一步了解该字段所在类System.Runtime.InteropServices.DllImportAttribute 的用法示例。
在下文中一共展示了DllImportAttribute.PreserveSig字段的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Win32
' 导入命名空间
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Module Win32
' The SHAutoComplete function allows you
' to add auto-compete functionality to your
' Windows Forms text boxes. In .NET Framework
' 1.1 and earlier, you can use SHAutoComplete.
' Later versions have this ability built in without
' requiring platform invoke.
' See the MSDN documentation of the
' SHAutoComplete function for the
' complete set of flags.
Public Enum SHAutoCompleteFlags
SHACF_DEFAULT = &H1
SHACF_FILESYSTEM = &H1
End Enum
' Use the DllImportAttribute to import the SHAutoComplete function.
' Set the PreserveSig to false to specify exception errors.
<DllImportAttribute("shlwapi.dll", EntryPoint:="SHAutoComplete", ExactSpelling:=True, PreserveSig:=False)> _
Public Sub SHAutoComplete(ByVal hwndEdit As IntPtr, ByVal dwFlags As SHAutoCompleteFlags)
End Sub
' Use the DllImportAttribute to import the SHAutoComplete function.
' Use the default value of the PreserveSig field to specify HRESULT errors.
<DllImportAttribute("shlwapi.dll", EntryPoint:="SHAutoComplete", ExactSpelling:=True)> _
Public Function SHAutoCompleteHRESULT(ByVal hwndEdit As IntPtr, ByVal dwFlags As SHAutoCompleteFlags) As Integer
End Function
End Module
Module Program
Sub Main()
Run()
End Sub
Sub Run()
' Create a null (nothing in Visual Basic) IntPtr
' to pass to the SHAutoComplete method. Doing so
' creates a failure and demonstrates the two ways
' that the PreserveSig property allows you to handle
' failures.
' Normally, you would pass a handle to a managed
' Windows Forms text box.
Dim iPtr As New IntPtr(0)
' Call the SHAutoComplete function using exceptions.
Try
Console.WriteLine("Calling the SHAutoComplete method with the PreserveSig field set to false.")
Win32.SHAutoComplete(iPtr,Win32.SHAutoCompleteFlags.SHACF_DEFAULT)
Catch e As Exception
Console.WriteLine("Exception handled: " + e.Message)
End Try
Console.WriteLine("Calling the SHAutoComplete method with the PreserveSig field set to true.")
' Call the SHAutoComplete function using HRESULTS.
Dim HRESULT As Integer = Win32.SHAutoCompleteHRESULT(iPtr,Win32.SHAutoCompleteFlags.SHACF_DEFAULT)
Console.WriteLine("HRESULT handled: " + HRESULT.ToString())
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Runtime.InteropServices,代码行数:76,代码来源:DllImportAttribute.PreserveSig
注:本文中的System.Runtime.InteropServices.DllImportAttribute.PreserveSig字段示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论