DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DDC_OpenFile Error(-6209) with VB.NET

I used the DDC_OpenFile function of C_DLL_TDM.uri with VB.NET.
The result was Error code  "-6209 FileDoesNotExist".
As VB.NET uses UTF-16 for the character string, I converted it to EUC. Also,I changed FilePath from the Windows format"C:\Users\laser\Desktop\TDMS\A.tdms" to the C format"C:\\Users\\laser\\Desktop\\TDMS\\A.tdms".
※Of course the TDMS file is in place
Refer the code below.

Class TestProgram

<DllImport("C:\Users\laser\Desktop\TDM C DLL\dev\bin\64-bit\nilibddc.dll")>
Private Shared Function DDC_OpenFile(ByRef filePath() As System.Byte, ByRef fileType() As System.Byte, ByRef file As Long) As Integer
'ByRef filePath() As System.Byte, ByRef fileType() As System.Byte, ByRef file As Long) As Integer

End Function

Public Shared Sub Main()
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)
Dim ret As Integer
Dim file As Long
Dim str As String
Dim filePathbytes() As Byte
Dim fileTypebytes() As Byte

str = "C:\\Users\\laser\\Desktop\\TDMS\\A.tdms"
filePathbytes = Encoding.GetEncoding("EUC-JP").GetBytes(str) '*** UTF16 to EUC

Console.WriteLine(BitConverter.ToString(filePathbytes))

str = "TDMS"
fileTypebytes = Encoding.GetEncoding("EUC-JP").GetBytes(str) '*** UTF16 to EUC

Console.WriteLine(BitConverter.ToString(fileTypebytes))

ret = DDC_OpenFile(filePathbytes, fileTypebytes, file)

Debug.Print(ret)
Debug.Print(file)
End Sub
End Class

Please tell me what is the problem.

0 Kudos
Message 1 of 1
(1,404 Views)