我想调用wintrust.dll中可用的函数CryptCATCatalogInfoFromContext。但是当我这样做时,我收到一条错误消息,指出指定的数组不是预期的类型。 我正在使用以下代码来调用方法。我使用的某些数据类型似乎与所需的数据类型不匹配。
'import wintrust.dll
<DllImport("Wintrust.dll", PreserveSig:=True, SetLastError:=False)> _
Private Shared Function CryptCATCatalogInfoFromContext(ByVal catalogContext As IntPtr, ByVal hash As CATALOG_INFO_, ByVal dwFlags As Integer) As Boolean
End Function
'create structure CATALOG_INFO
<StructLayout(LayoutKind.Sequential)> _
Public Structure CATALOG_INFO_
Public cbStruct As UInteger
<MarshalAs(UnmanagedType.SafeArray)> _
Public wszCatalogFile() As Char
End Structure
我已经获得了 CatalogContext。
Dim infoStruct As New CATALOG_INFO_()
infoStruct.cbStruct = 256
Dim c(255) As Char
infoStruct.wszCatalogFile = c
CryptCATCatalogInfoFromContext(CatalogContext, infoStruct, 0)
最后一行抛出错误指定的数组不是预期的类型。 我是否为数组使用了错误的数据类型?