Trying to read a C dll and convert some code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bum
    New Member
    • Jan 2008
    • 19

    Trying to read a C dll and convert some code

    Hello all,

    I have a C dll I need to tap into and some C code to interpret to vb.net 2005, but am so far unsuccessful. I just get the generic "runtime has encountered a fatal error at XXXXXX memory". I think my prob is passing the variables. Also, I know the * refers to pointers, but not sure how to interpret them. Hope someone can help...

    'Here is the C Code:


    [CODE=c]enum XXXXStatus {StatusUnknown = 0,
    Processed,
    NoSuchSession,
    NoSuchInfo,
    ReadOnlyInfo,
    InvalidInfo,
    NotYetImplement ed = -1};

    enum DataEncoding {EncodingUnknow n = 0,
    NoValue,
    ZeroTerminatedS tring,
    Short16,
    Int32,
    Double64,
    Boolean8,
    Char8,
    BinaryByte8
    };

    #define XXXX_INFO_ID_LE NGTH 32

    struct XXXXSessionInfo Parameter {
    char InfoID[XXXX_INFO_ID_LE NGTH];
    int InfoValueLength ; /* Total bytes */
    enum DataEncoding InfoEncoding;
    int InfoDataCount; /* Number of values or elements */
    void *InfoData;
    };


    struct XXXXSessionInfo Response {
    enum XXXXStatus Status;
    char InfoID[XXXX_INFO_ID_LE NGTH];
    int InfoParameterCo unt;
    struct XXXXSessionInfo Parameter *InfoParameterL ist;
    };


    struct XXXXSessionInfo Response __declspec (dllexport) *XXXXGetSession Info (unsigned long SessionID, char *InfoID);[/CODE]


    'here's the call in C:

    Info = XXXXGetSessionI nfo (SessionID, “SystemInventor y”)


    'now here's what I have sofar in VB.net:

    [CODE=vbnet]Public Enum DataEncoding
    EncodingUnknown = 0
    NoValue
    ZeroTerminatedS tring
    Short16
    Int32
    Double64
    Boolean8
    Char8
    BinaryByte8
    End Enum

    Public Enum XXXXStatus
    StatusUnknown = 0
    Processed
    NoSuchSession
    NoSuchInfo
    ReadOnlyInfo
    InvalidInfo
    RequestComplete
    NotYetImplement ed = -1
    End Enum

    <DllImport("XXX Xapi.dll", EntryPoint:="XX XXGetSessionInf o", ExactSpelling:= False, CharSet:=CharSe t.Unicode)> _
    Public Function XXXXGetSessionI nfo(ByVal SessionID As ULong, ByRef InfoID As String) As XXXXSessionInfo Response
    End Function

    Public Class XXXXSessionInfo Parameter
    <MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=32)> Public InfoID As String
    Public InfoValueLength As Integer ' Total bytes
    Public InfoEncoding As DataEncoding
    Public InfoDataCount As Integer ' Number of values or elements
    Public InfoData As IntPtr
    End Class

    Public Class XXXXSessionInfo Response
    Public Status As XXXXStatus
    <MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=32)> Public InfoID As String
    Public InfoParameterCo unt As Integer
    Public InfoParameterLi st As XXXXSessionInfo Parameter
    End Class[/CODE]

    'heres the call I use in vb.net:

    [CODE=vbnet]dim Info As XXXXSessionInfo Response

    'please note sessionID was given in earlier code not shown
    Info = XXXXGetSessionI nfo(SessionID, "SystemInventor y")[/CODE]

    Thanks in advance! B
    Last edited by Killer42; Feb 14 '08, 01:44 AM. Reason: Added CODE tags
Working...