473,804 Members | 3,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to read a C dll and convert some code

19 New Member
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:


Expand|Select|Wrap|Line Numbers
  1. enum XXXXStatus {StatusUnknown = 0, 
  2.           Processed, 
  3.           NoSuchSession,
  4.           NoSuchInfo, 
  5.           ReadOnlyInfo,
  6.           InvalidInfo,
  7.           NotYetImplemented = -1};
  8.  
  9. enum DataEncoding {EncodingUnknown = 0, 
  10.         NoValue,
  11.         ZeroTerminatedString, 
  12.         Short16, 
  13.         Int32, 
  14.         Double64, 
  15.         Boolean8, 
  16.         Char8, 
  17.         BinaryByte8
  18.                                 };
  19.  
  20. #define XXXX_INFO_ID_LENGTH    32
  21.  
  22. struct XXXXSessionInfoParameter {
  23.     char          InfoID[XXXX_INFO_ID_LENGTH];
  24.     int    InfoValueLength;        /* Total bytes */
  25.     enum        DataEncoding        InfoEncoding;
  26.     int            InfoDataCount;    /* Number of values or elements */
  27.     void         *InfoData;
  28. };
  29.  
  30.  
  31. struct XXXXSessionInfoResponse {
  32.     enum XXXXStatus     Status;
  33.     char    InfoID[XXXX_INFO_ID_LENGTH];
  34.     int             InfoParameterCount;
  35.     struct    XXXXSessionInfoParameter         *InfoParameterList;
  36. };
  37.  
  38.  
  39. struct XXXXSessionInfoResponse __declspec (dllexport) *XXXXGetSessionInfo (unsigned long SessionID,  char    *InfoID);

'here's the call in C:

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


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

Expand|Select|Wrap|Line Numbers
  1. Public Enum DataEncoding
  2.         EncodingUnknown = 0
  3.         NoValue
  4.         ZeroTerminatedString
  5.         Short16
  6.         Int32
  7.         Double64
  8.         Boolean8
  9.         Char8
  10.         BinaryByte8
  11.     End Enum
  12.  
  13.     Public Enum XXXXStatus
  14.         StatusUnknown = 0
  15.         Processed
  16.         NoSuchSession
  17.         NoSuchInfo
  18.         ReadOnlyInfo
  19.         InvalidInfo
  20.         RequestComplete
  21.         NotYetImplemented = -1
  22.     End Enum
  23.  
  24.    <DllImport("XXXXapi.dll", EntryPoint:="XXXXGetSessionInfo", ExactSpelling:=False, CharSet:=CharSet.Unicode)> _
  25.     Public Function XXXXGetSessionInfo(ByVal SessionID As ULong, ByRef InfoID As String) As XXXXSessionInfoResponse
  26.     End Function
  27.  
  28.  Public Class XXXXSessionInfoParameter
  29.         <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public InfoID As String
  30.         Public InfoValueLength As Integer ' Total bytes 
  31.         Public InfoEncoding As DataEncoding
  32.         Public InfoDataCount As Integer ' Number of values or elements 
  33.         Public InfoData As IntPtr
  34.     End Class
  35.  
  36. Public Class XXXXSessionInfoResponse
  37.         Public Status As XXXXStatus
  38.         <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public InfoID As String
  39.         Public InfoParameterCount As Integer
  40.         Public InfoParameterList As XXXXSessionInfoParameter
  41.     End Class
'heres the call I use in vb.net:

Expand|Select|Wrap|Line Numbers
  1. dim Info As XXXXSessionInfoResponse
  2.  
  3.      'please note sessionID was given in earlier code not shown
  4.      Info = XXXXGetSessionInfo(SessionID, "SystemInventory")
Thanks in advance! B
Feb 13 '08 #1
0 1104

Sign in to post your reply or Sign up for a free account.

Similar topics

7
17881
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm able to encrypt and then decrypt data okay as in the following code: // encrypt the data // Encryptor enc = new Encryptor(EncryptionAlgorithm.TripleDes); byte key = Encoding.ASCII.GetBytes("0123456789012345");
25
4079
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
19
1613
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
7
3414
by: poornesh K V | last post by:
This is the details: I have a Form : ProjectDetails This form is made up of a TabControl : maintabctrl1 (Say 10 pages) Each page has a subform : subForm1 This subForm1 has tabcontrol : tabctl1(say 10 pages)
2
2133
by: ratsat | last post by:
I have a database with over 100,000 records and the dates are all stored as text fields 01-JAN-1999. I need to convert them to a date field and have tried numerous options on my own and in examples posted on threads. I am in a crunch to get this done, need a quick fix from the experts! Thanks!
0
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.