Red Gate forums :: View topic - help with pinvoke and variant return type
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net
PInvoke.Net forum

help with pinvoke and variant return type

Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message
fhanggi



Joined: 15 Mar 2010
Posts: 1

PostPosted: Mon Mar 15, 2010 11:30 pm    Post subject: help with pinvoke and variant return type Reply with quote

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
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Tue Apr 13, 2010 2:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic 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