roidy said:
Ok this is what I`ve come up with so far to try out two of the api
calls:-
Public Class Form1
Declare Auto Function MP4GetMetadataName Lib "e:\libmp4v2.dll"
(ByVal filehandle As Integer, ByRef val As IntPtr) As Boolean
Declare Auto Function MP4Read Lib "e:\libmp4v2.dll" (ByVal
filename As String) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim filehandle As Long
Dim result As Boolean
Dim test As IntPtr
filehandle = MP4Read("e:\test.mp4")
result = MP4GetMetadataName(filehandle, test)
End Sub
End Class
The equivalent c code is as follows:-
char *value;
bool result;
MP4FileHandle mp4file = MP4Read( "e:\test.mp4");
result = MP4GetMetadataName( mp4file, &value );
However I get an "Arithmetic operation resulted in an overflow"
exception on the call to MP4GetMetadataName in the VB version.
Anybody know where I`m going wrong?
Yes, you use wrong declarations and you don't use them not correctly. Where
did you get them from?
These are the original declarations:
typedef void* MP4FileHandle;
bool MP4GetMetadataName(MP4FileHandle hFile, char** value);
MP4FileHandle MP4Read(const char* fileName, uint32_t verbosity
DEFAULT(0));
This is just an attempt to find the closest possible declarations:
Declare Auto Function MP4GetMetadataName Lib "e:\libmp4v2.dll"
(ByVal filehandle As IntPtr, ByRef val As IntPtr) As Boolean
Declare Auto Function MP4Read Lib "e:\libmp4v2.dll" (ByVal
filename As String, byval verbosity as UInteger) As IntPtr
Call:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim filehandle As IntPtr
Dim result As Boolean
Dim test As IntPtr
Dim bytes(1023) As Byte
filehandle = MP4Read("e:\test.mp4", ???) '<-- don't know what to pass
Dim gch = Runtime.InteropServices.GCHandle.Alloc(bytes(0))
result = MP4GetMetadataName(filehandle, gch.AddrOfPinnedObject())
gch.Free()
End Sub
Maybe (hopefully) there is another way to translate a char**. You have to
convert the byte array to a String using one of the System.Text.Encoding
objects.
Armin