Baha Dzhan
Baha Dzhan

Reputation: 11

How to call function of unmanaged code from vb.net with reference (pointer) out value?

I have function PLInsert2D Also it has description in unmanaged code like this:

HRESULT PLInsert2D(
[in] IPARTLibProvider* aPLClient;
[in] IBOResponseDisp* aMethodResponse;
[in] Double aX, aY, aAngle;
[out, retval] long* result); 

I call this function from vb.net vs 2017 win8.1 64bit:

<DllImport("C:\Program Files\ASCON\KOMPAS-3D v17\Libs\PARTLib\Clients\plclient_kompas.dll", BestFitMapping:=True, CallingConvention:=CallingConvention.StdCall, EntryPoint:="LIBRARYENTRY")>
    Public Shared Function PLInsert2D(<MarshalAs(UnmanagedType.Interface)> ByVal aPLClient As IPARTLibProvider, <MarshalAs(UnmanagedType.Interface)> ByVal aMethodResponse As IBOResponse, ByVal aX As Double, ByVal aY As Double, ByVal aAngle As Double) As IntPtr
    End Function

and I use it in managed code like this:

Dim insert2dpart As IntPtr
        insert2dpart = PLInsert2D(aPLClient, aMethodResponse, aX, aY, aAngle)

It returns &H0000000000000001 What is this? Is this good or bad? What can I do with this value? It should return reference of macroelement, but I think this is not what I expect. Any help would be appreciated. Thanks!

Upvotes: 0

Views: 122

Answers (0)

Related Questions