473,503 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Marshaling structure with pointer to array of strings

I am struggling with the following

How do I marshal/access a pointer to an array of strings within a structure

Than

Jef

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

namespace Win32Wrapper

...

/
typedef struct
unsigned long flag; // function rule
unsigned long timeout_msec; // maximum allowed tim
unsigned long version_major
unsigned long version_minor
my_tag_list_t *taglist; // pointer to tag lis
unsigned int start_tag; // first tag to be processe
unsigned int end_tag; // last tag to be processe
unsigned int valid_tags; // number of valid taglist entrie
unsigned int max_tags; // maximum size of taglis
signed long status; // overall function statu
signed long *istatus; // pointer to input status lis
signed long *ostatus; // pointer to output status lis
signed long **field_status; // pointer to array of arrays of statu
signed long **field_status_save;// pointer to saved field_statu
unsigned long select_list_number; // the selection list numbe
char *select_equation; // pointer to select lis
unsigned int fields; // number of field name
char **field_name; // pointer to arrays of name
void **tag_field_value; // pointer to array of arrays of value
void **field_value; // pointer to array of constant value
my_physadrs_t **physadrs; // pointer to array of arrays of addres
my_physadrs_t **physadrs_save; // to saved physadr
my_access_ids_t **access_ids; // ptr to array of lists of stuf
void *custom_table; // ptr to config dat
char *cust_file_name; // ptr to name of vendor-specific cfg fil
} myType2
*
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)
public class myType2
public uint flag; // function rule
public uint timeout_msec; // maximum allowed tim
public uint version_major
public uint version_minor
public IntPtr taglist; // pointer to tag lis
public uint start_tag; // first tag to be processe
public uint end_tag; // last tag to be processe
public uint valid_tags; // number of valid taglist entrie
public uint max_tags; // maximum size of taglis
public int status; // overall function statu
public IntPtr istatus; // pointer to input status lis
public IntPtr ostatus; // pointer to output status lis
public IntPtr field_status; // pointer to array of statu
public IntPtr field_status_save; // pointer to saved field_statu
public uint select_list_number; // the selection list numbe
public IntPtr select_equation; // pointer to select lis
public uint fields; // number of field name
public IntPtr field_name; // pointer to array of field name
public IntPtr tag_field_value; // pointer to array of value
public IntPtr field_value; // pointer to array of constant value
public IntPtr physadrs; // pointer to array of addresse
public IntPtr physadrs_save; // to saved physadr
public IntPtr access_ids; // ptr to array of lists of stuf
public IntPtr custom_table; // ptr to config dat
public IntPtr cust_file_name; // ptr to name of cfg fil
} // myType

public class RfidWrapper

...

/
EXPORT_CFUNC signed long EXPORT_STDCALL GetFieldNames(myType1 *aType1, myType2 *aType2, signed long *status)
*
[DllImport("D:\\Progra~1\\Intermec\\Intell~1\\it500 .dll")
public static extern int GetFieldNames([In, Out] myType1 aType1, [In, Out] myType2 aType2, out int Status)

....

} // public class Win32Wrapper
} // namespace MyStuff
// Calling program
....
rc = Win32Wrapper.GetFieldNames(aType1, aType2, out nStatus);

//
// How do I marshal aType2 to access field_name[] that is an array of strings???
// i.e. aType2.field_name[valid_tags]
//
....
Nov 16 '05 #1
1 3077

Marshal.ReadIntPtr() to retrieve one of the string pointers in the
array, then call Marsahal.PtrToStringAnsi() with the pointer to get
the string.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

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

Similar topics

3
2640
by: Nikolay Petrov | last post by:
Guys, please help. I am trying to make this work from at least 4 months. I am new to programming and some things are difficult to me, but I really need to make my project work. I can't find...
3
2972
by: Leo Nunez | last post by:
Hello! I need copy from structure "A" to "B" that contains "strings" in a one line code. Me problem like this : typedef struct tHeader{ char field1; char field2; char field3;
2
11930
by: vikas | last post by:
I have following structure in c++. typedef struct MMF_result_struct { int action; char text; int cols,rows; int month,day,year; } MMF_result; Now this structure is shared between C++ and C#...
2
1859
by: Pas de Spam | last post by:
Hi, I have some problem in marshaling array of structure. I have to exchange a structure of data with a C++ program. This structure data contains a field which is an array of a custom type. I...
1
6762
by: ivang | last post by:
Hello, All! Please help me to marshal following win32 structure: typedef struct _STARTUPINFOW { DWORD cb; LPWSTR lpReserved;
3
2324
by: Sin | last post by:
Hello everybody, I'm currently trying to understand how marshaling can use used for accessing Win32 API functions as well as custom C/C++ code we design which exposes functions the same way as...
6
4191
by: Tom | last post by:
I'm trying to pass this structure to a dll: <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _ Public Structure udtINTER01 <VBFixedString(8),...
2
1949
by: Laurent | last post by:
Hi again, I created a thread some days ago, while I was trying to access a C++ DLL using my C# program. First of all, I want to thanks all the guys who helped me. But I still have a...
6
5883
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
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...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
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...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
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 ...
1
731
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.