我正在使用VB.Net在Excel中使用Api调用dll。 (罗伯特·吉塞克的不受管制的出口) 标准类型(数字,字符串)正在运行。但是,当尝试使用对象类型时,返回错误。
错误消息是: “未知名称。(返回HRESULT异常:0x80020006(DISP_E_UNKNOWNNAME))”
我的功能是(错误是IPictureDisp到位图):
Public Function GetTextQR_FromPicture(ByVal pictureDisp As IPictureDisp) As [MarshalAs(UnmanagedType.BStr)] String
'IPictureDisp
Return _qrDec.decode(New QRCodeBitmapImage(PicHelper.GetPictureFromIPictureDisp(pictureDisp)), Encoding.UTF8)
End Function
我的助手班:
Friend Class PicHelper
Inherits System.Windows.Forms.AxHost
Friend Sub New()
MyBase.New(Nothing)
End Sub
Friend Shared Shadows Function GetIPictureDispFromPicture(image As Image) As Object
Return System.Windows.Forms.AxHost.GetIPictureDispFromPicture(image)
End Function
Friend Shared Shadows Function GetPictureFromIPictureDisp(picture As IPictureDisp) As Image
Return System.Windows.Forms.AxHost.GetPictureFromIPictureDisp(picture)
End Function
End Class