| Author |
Message |
fhanggi
Joined: 15 Mar 2010 Posts: 1
|
Posted: Mon Mar 15, 2010 11:30 pm Post subject: help with pinvoke and variant return type |
|
|
Could anyone please help me write a pinvoke statement for this function?
[id(0x60030004)]
HRESULT AFAccountPayment(
[in] VARIANT coForm,
[in, out, optional] BSTR* billlist,
[out, retval] VARIANT* );
I have tried a few things but it's not working. I don't know how to code the VARIAN* retval properly.
Mostly i get an error: PInvoke restriction: cannot return variants.
Here is what i have tried so far.
<DllImport("c:\windows\system32\nctk.dll")> _
Public Shared Function AFAccountPayment(ByVal coForm As Object, Optional ByRef billList As String = "") As Object
End Function
<DllImport("c:\windows\system32\nctk.dll")> _
Public Shared Function AFAccountPayment(<Out(), MarshalAs(UnmanagedType.Struct)> ByVal coForm As Object, <[In](), [Out](), MarshalAs(UnmanagedType.VBByRefStr)> Optional ByRef billList As String = Nothing) As Object
End Function
Thank you for any help. |
|
| Back to top |
|
 |
Paul.Martin
Joined: 03 Feb 2010 Posts: 83 Location: Cambridgeshire
|
Posted: Tue Apr 13, 2010 2:18 pm Post subject: |
|
|
The best thing I can think of suggesting (without knowing what the VARIANT* will actually be pointing to and if it will be marshallable) is changing the semantics of the PInvoke call. So you could try something like:
<DllImport("c:\windows\system32\nctk.dll")> _
Public Shared Function AFAccountPayment(<Out(), MarshalAs(UnmanagedType.Struct)> ByVal coForm As Object, <[In](), [Out](), MarshalAs(UnmanagedType.VBByRefStr)> Optional ByRef billList As String = Nothing, <Out(), MarshalAs(UnmanagedType.Struct)> ByRef varRet As Object) As IntPtr
End Function |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group