0

次のAPIをVB.NETに変換する方法がわかりません

Private Const MAXPNAMELEN As Long = 32&

Private Type JOYCAPS
wMid As Integer
wPid As Integer
szPname As String * MAXPNAMELEN
wXmin As Long
wXmax As Long
wYmin As Long
wYmax As Long
wZmin As Long
wZmax As Long
wNumButtons As Long
wPeriodMin As Long
wPeriodMax As Long
End Type

Private Declare Function joyGetDevCaps Lib "winmm.dll" Alias "joyGetDevCapsA" (ByVal id As Long, lpCaps As JOYCAPS, ByVal uSize As Long) As Long

いくつかのコンバーターを試しましたが、出力されたものが機能しませんでした。誰かが本当に良い人なら、彼は私のためにそれを変換して、それを呼び出す方法を教えてくれるでしょうか?特に、JOYCAPSを関数に渡すときにインスタンス化する方法がわかりません。

pinvoke.netでこの関数が見つかりませんでした。

ありがとうございました。

4

1 に答える 1

2

テストすることはできませんが、これは簡単な変換である必要があります。

Private Const MAXPNAMELEN As Integer = 32

<StructLayout(LayoutKind.Sequential)>
Private Structure JOYCAPS
    Public wMid As Short
    Public wPid As Short
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAXPNAMELEN)>
        Public szPname As String
    Public wXmin As Integer
    Public wXmax As Integer
    Public wYmin As Integer
    Public wYmax As Integer
    Public wZmin As Integer
    Public wZmax As Integer
    Public wNumButtons As Integer
    Public wPeriodMin As Integer
    Public wPeriodMax As Integer
End Structure

<DllImport("winmm.dll")>
Private Shared Function joyGetDevCaps(id As IntPtr, ByRef lpCaps As JOYCAPS, uSize As UInteger) As Integer

End Function

System.Runtime.InteropServicesインポートされていることを前提としています。

于 2012-12-16T17:55:10.567 に答える