Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Zugriff auf nicht verwaltete dll

6 views
Skip to first unread message

Patrick Denke

unread,
Feb 7, 2012, 9:28:16 AM2/7/12
to
Ich habe eine dll von einem Zulieferer, welcher folgende Funktion

Bereitstellt (Beschreibung des Herstellers):



C++

bool __stdcall GetSINCOSBufValue (long DevNum, long Index, unsigned

char* sinx, unsigned char* cosx);



Delphi

function GetSINCOSBufValue (DevNum, Index : integer; var SINX,CosX :
byte) : boolean;



Diese habe ich bisher erfolgreich unter VB6 genutzt mit folgender

Deklaration:

Private Declare Function GetSINCOSBufValue Lib "siosusb.dll" (ByVal
DevNumber&, ByVal Index&, sinx As Byte, siny As Byte) As Byte



und folgendem Aufruf:

Dim sinx() As Byte, siny() As Byte

ReDim sinx(anzahl - 1), siny(anzahl - 1)

For ind = 0 To anzahl - 1

dummy = GetSINCOSBufValue(0, CLng(ind), sinx(ind), siny(ind))

Next



anzahl ist mir aus seiner anderen Funktion bekannt.



Unter VB.Net habe ich folgendes probiert:



Deklaration:

<DllImportAttribute("siosusb.dll", EntryPoint:="GetSINCOSBufValue",
CallingConvention:=CallingConvention.StdCall)> _

Public Shared Function GetSINCOSBufValue(ByVal DevNum As Integer, ByVal
Index As Integer, ByRef sinx As Byte, ByRef cosx As Byte) As
<MarshalAsAttribute(UnmanagedType.I1)> Byte

End Function



Aufruf:

Dim sinx As New List(Of Byte), siny As New List(Of Byte)

For ind As Integer = 0 To CInt(anzahl - 1)

Dim x As Byte, y As Byte

GetSINCOSBufValue(0, ind, x, y)

sinx.Add(x)

siny.Add(y)

Next



Ich bekomme unter VB.Net leider nur Nullen zurück.

Ich kann aber auch in der Deklaration ByRef sinx As Byte, ByRef cosx As
Byte ersetzen durch ByRef XPointer As IntPtr, ByRef YPointer As IntPtr
und entsprechend auch im Aufruf.

Ich bekomme dann auch Werte, die Zeiger sein könnten. Wie komme ich dann
aber an die Daten?



Gruß Patrick




0 new messages