我正在使用VB.NET并从System-DLL获取一个图标。因此,我使用ExtractIconEx
。正如在评论中所提到的,我正在使用DestroyIcon
来再次释放资源。
到目前为止,我使用了
行Private Declare Auto Function DestroyIcon Lib "user32.dll" (
ByVal hIcon As IntPtr) As Boolean
声明该方法。
从Icon.FromHandle
的{{3}}示例,我看到他们使用
<System.Runtime.InteropServices.DllImportAttribute("user32.dll")> _
Private Shared Function DestroyIcon(
ByVal hIcon As IntPtr) As Boolean
End Function
有什么区别?
我特别想到DllImportAttribute
似乎与Declare
同样轻松。我做了以下测试:
我使用this从ini文件中获取字符串。
Private Declare Auto Function GetPrivateProfileString Lib "kernel32" (
ByVal lpApplicationName As String,
ByVal lpKeyName As String,
ByVal lpDefault As String,
ByVal lpReturnedString As String,
ByVal nSize As Integer,
ByVal lpFileName As String) As Integer
工程;它将条目写入lpReturnedString
缓冲区并返回41.
<System.Runtime.InteropServices.DllImportAttribute("kernel32.dll")> _
Private Shared Function GetPrivateProfileString(
ByVal lpApplicationName As String,
ByVal lpKeyName As String,
ByVal lpDefault As String,
ByVal lpReturnedString As String,
ByVal nSize As Integer,
ByVal lpFileName As String) As Integer
End Function
保持lpReturnedString
不变,但返回正确的字符串长度41。