UPDATE: Thanks for everyones help. I had no idea about Marshaling my Strings and after doing so everything is now working correctly. I have edited my code below for others who may find this issue
I am currently working on porting some VB6 code to .net the vb6 application is using a precompiled .dll (made in C++ I beleive) and I do not have any access to its source code.
When googling the function name I get only one google result which DOES have information on its return value and its parameters and I believe I have declared the .DLL correctly
http://jelleybee.com/fun/vgames/emulate/snes/setup/super%20jukebox/Uematsu.html
.DLL function declaration
Declare Function Uematsu_LoadID666Tag Lib "uematsu.dll" (ByVal lpszFileName As String, ByRef lpTag As ID666_tag) As Boolean
I have defined my structure like this
Public Structure ID666_tag
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Song As String 'Title of song
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Game As String 'Name of game
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Artist As String 'Name of artist
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Dumper As String 'Name of dumper
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Dated As String 'Date dumped
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Emu As String 'Emulator used to dump
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Comment As String 'Optional comment
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public OST As String 'Origonal soundtrak title
Public SongLength As Integer 'Length of song
Public LoopLength As Integer 'Length of the loop (extended ID666)
Public EndLength As Integer 'Length of end (extended ID666)
Public FadeLength As Integer 'length of fade out
Public OSTDiscNum As Byte 'Origonal sound track disc number
Public OSTTrack As Short 'Original sound track track number
Public Publisher As String 'Name Of Publisher
Public Copyright As Short 'Date of Copyright
Public Mute As Byte 'Channels to mute
End Structure
I am using the function like this
Function Extract_ID666(Fname As String) As ID666_tag
Dim TempExtr As ID666_tag
If Uematsu_LoadID666Tag(Fname, TempExtr) = True Then
MessageBox.Show("DONE")
Else
MessageBox.Show("FAIL")
End If
End Function
However when ever I run my Extract_ID666 function I receive an access violation error.
I know this has something to do with the way I setup to use TempExtr or how I have declared my .dll function. But I can not track it down.
Any ideas or solutions to this problem would be much appreciated. I have searched SO for a long time trying to find a similar question but could not find a solution.