V module mam naimportovanu fnc a k nej structuru
Module Module1
<DllImport("winmm.dll", entrypoint:="waveOutGetDevCapsW")> Public Function waveOutGetDevCaps(ByVal uDeviceID As Integer, ByRef pwoc As WAVEOUTCAPS, ByVal cbwoc As Integer) As Integer
End Function
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)> Public Structure WAVEOUTCAPS
Public wMid As Short
Public wPid As Short
Public vDriverVersion As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public szPname As String
Public dwFormats As Integer
Public wChannels As Short
Public wReserved1 As Short
Public dwSupport As Integer
End Structure
End Module
a potom to volam z tlacidla
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ee As WAVEOUTCAPS
Dim i As Integer
i = waveOutGetDevCaps(TextBox2.Text, ee, Marshal.SizeOf(ee))
If i = 0 Then Me.Text = "OK " Else Me.Text = "ERROR" : Exit Sub
Debug.Print(ee.szPname.Length)
TextBox1.Text = ee.szPname.ToString
End Sub
Problem je v tom, ze aj ked mam szPname definovane ako fix s velkostou 128, aj tak mi to stale orezava na 32 znakov (posledny je null char). Neviete ako to napravit a dost cely string, ktory tam mam definovany?
|