|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Unmanaged C++ Void*trying to call is declared like this: void* PASCAL iidc_lockdata( HIIDC, long frame = -1 ) This function returns a pointer to unsigned chars I am able to find the size of the array out. It is usually 128800 to use as an example if it helps. I have declared the interface for my VB.NET as follows: Private Declare Function _iidc_lockdata Lib "iidcapi_SONY.dll" Alias "#37" (ByVal HIIDC As Int32, ByVal frame As Int32) As System.Runtime.InteropServices.GCHandle and also I have tried it as Private Declare Function _iidc_lockdata Lib "iidcapi_SONY.dll" Alias "#37" (ByVal HIIDC As Int32, ByVal frame As Int32) As IntPtr (1) My first question is, how do I declare the function, should I use GCHandle or IntPtr or something else? As far as calling the function goes, I have tried this: Dim gch As System.Runtime.InteropServices.GCHandle gch = New System.Runtime.InteropServices.GCHandle Dim lBufSz As Int32 = camera.currentDataFrameBytes(m_hCamera) gch.Alloc(lBufSz) Try gch = camera.lockdata(m_hCamera, -1) gch.Free() Catch ex As Exception MsgBox(ex.Message) End Try FYI the function camera.lockdata is a mapped function and it is as follows: Public Function lockdata(ByVal HIIDC As Int32, ByVal frame As Int32) As System.Runtime.InteropServices.GCHandle Return _iidc_lockdata(HIIDC, frame) End Function and I get "Object reference not set to an instance of an object" (2) How would I get the data? I have been really struggling with this. Thanks, Mike Dixon Mike,
>(1) My first question is, how do I declare the function, should I use IntPtr>GCHandle or IntPtr or something else? >(2) How would I get the data? System.Runtime.InteropServices.Marshal.CopyMattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Hi,
The function should return an intptr. You should be able to use marshal.ptrtostructure or one of the marshal.pointertostring function to get the data. http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.marshal_members.aspx Ken --------------- Show quoteHide quote "Frustrated" wrote: > I have a C++ DLL that I need to access from VB.NET. The function I am > trying to call is declared like this: > > void* PASCAL iidc_lockdata( HIIDC, long frame = -1 ) > > This function returns a pointer to unsigned chars > > I am able to find the size of the array out. It is usually 128800 to > use as an example if it helps. > > I have declared the interface for my VB.NET as follows: > > Private Declare Function _iidc_lockdata Lib "iidcapi_SONY.dll" Alias > "#37" (ByVal HIIDC As Int32, ByVal frame As Int32) As > System.Runtime.InteropServices.GCHandle > > and also I have tried it as > > Private Declare Function _iidc_lockdata Lib "iidcapi_SONY.dll" Alias > "#37" (ByVal HIIDC As Int32, ByVal frame As Int32) As IntPtr > > (1) My first question is, how do I declare the function, should I use > GCHandle or IntPtr or something else? > > As far as calling the function goes, I have tried this: > > Dim gch As System.Runtime.InteropServices.GCHandle > gch = New System.Runtime.InteropServices.GCHandle > Dim lBufSz As Int32 = camera.currentDataFrameBytes(m_hCamera) > gch.Alloc(lBufSz) > Try > gch = camera.lockdata(m_hCamera, -1) > gch.Free() > Catch ex As Exception > MsgBox(ex.Message) > End Try > > FYI the function camera.lockdata is a mapped function and it is as > follows: > > Public Function lockdata(ByVal HIIDC As Int32, ByVal frame As Int32) > As System.Runtime.InteropServices.GCHandle > Return _iidc_lockdata(HIIDC, frame) > End Function > > > and I get "Object reference not set to an instance of an object" > > (2) How would I get the data? > > I have been really struggling with this. > > Thanks, > Mike Dixon > >
le nom 'vb6' n'est pas déclaré
How to Automatically Update UI When Data Changes Overload resolution failed All I'm looking for is a simple answer to a simple question DataGrid Control How do I use a class, when the class requires functions in the main form? Object-to-Relational Tool Memory Manipulation Error while file copying over network. Shell IE ? |
|||||||||||||||||||||||