473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

marshal complex structure to C dll

Hi All,

I have a problem with marshaling complex structures (containing numbers,
strings, arrays of another structures) to native C function in dll.
I have already posted same question to .compactframework thread, but nobody
helped.

main problem is that I have tried all the workarounds I have found in the
Inet but nothing worked...
I tried passing IntPtr, Byte Arrays, Serialisation, even used OpenNETCF, but
all failed.

I have even compiled own dll with same structures and functions, and there I
can see what is passed in params and can return needed values. Result - the
structure I pass to the function is empty and the structure I return from
the function is not retrieved to outside (I have same structure that passed
to function with no changes)

any ideas?

thanks in advance for any help.
Ivan.

--------------------

typedef struct tagACROSS_CLUE {
unsigned int numClue; /* Clue number */
LPCWSTR strClue; /* The clue - clue number not included in the string */
} ACROSS_CLUE;

typedef struct tagACROSS_EXTDATA {
unsigned char extDataSignature[4]; /* Four byte character signature */
unsigned int dataSize; /* Size of extended data in bytes */
char * extData; /* uninterpreted bytes of data */
} ACROSS_EXTDATA;

typedef struct tagACROSS_HEADER {
BYTE bytes[44]; /* Uninterpreted bytes from the header */
} ACROSS_HEADER;

typedef struct tagACROSS_PUZZLE_DATA {
unsigned int struct_size; /* size of the data structure passed in bytes
must be initialized */
unsigned int szAcross; /* Grid size - No. of cells across */
unsigned int szDown; /* Grid Size - No. of cells down */
unsigned int numAClues; /* Total No. of Across clues */
unsigned int numDClues; /* Total No. of Down clues */
int flagsDescr; /* Puzzle flags */
int numCodeSet; /* Character code set used for the puzzle */
unsigned int numPtrSolnKey; /* For saving, if solution is to be locked,
the 4 digit lock key is returned here For reading, this is not used */
LPCWSTR strTitle; /* Puzzle Title */
LPCWSTR strAuthor; /* Puzzle Author */
LPCWSTR strCopyright; /* Puzzle Copyright */
LPCWSTR charsGrid; /* Puzzle Grid with solution */
LPCWSTR strNote; /* Puzzle notepad entry. Max length 1023 characters */
ACROSS_CLUE * cluesAcross;/* Pointer to array of Across clues */
ACROSS_CLUE * cluesDown; /* Pointer to array of Down clues */
unsigned int numExtData; /* Number of extended data structures */
ACROSS_EXTDATA * extDataList; /* Pointer to array of extended data
structures */
} ACROSS_PUZZLE_DATA;

ACLIB_API int ACROSS_InputPuzzle(LPCWSTR filename,

ACROSS_PUZZLE_DATA * puzzleDescriptor);

/* filename - Complete path name of file to read puzzle from */

/* puzzleDescriptor - Pointer to structure that will contain puzzle
data. */
Nov 21 '05 #1
0 1608

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ivan | last post by:
Hi All, I have a problem with marshaling complex structures (containing numbers, strings, arrays of another structures) to native C function in dll. I have already posted same question to...
3
by: kevin | last post by:
Hi I have a C struct that is of the following typedef struct{ DWORD num_conversions; ... short *sample_values; ....
2
by: twawsico | last post by:
I have a piece of code that needs to read the contents of a binary file (that I've created with another app) into an array of structures. The binary data in the file represents just a series of...
2
by: RYoung | last post by:
Given this native struct: typedef struct vendor { char name; } VENDOR I want to make managed equivalent, so I did this: public value struct Vendor
0
by: Paul | last post by:
I am trying to get the size of a structure that has an array of characters using the Marshal::SizeOf( ) method. The Marshal::SizeOf method fails because it says no meaningful size can be computer....
1
by: spamacon | last post by:
Hello, I have a strange situation using .Net FW 1.1. I want to use Marshal.PtrToStructure to fill the structure below. The first 3 fields get filled correctly: ulStruct describes how big the...
4
by: cleanrabbit | last post by:
Hello! I hate having to do this, because im almost certain there is someone in the world that has come across this problem and i just havent found their solution yet, so i do appologise if this...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
2
by: O.B. | last post by:
I have operation within a class that marshals the data into a byte array. Below are three different ways that work. Are there any downsides to using one over the the other? public virtual byte...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.