473,402 Members | 2,050 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,402 software developers and data experts.

Using a structure defined (unmanaged code) in a managed code.

Hello,

i want to use the unmanaged code in CSharp.

the structure defined in the cpp dll is

typedef struct XTRAP_CLIENT_LIST
{
char prnNetAdd[100];
char hostAddress[100];
XTYPE_ADDESS ClientType;
struct XTRAP_CLIENT_LIST* next;
} XTRAP_CLIENT_LIST;

typedef XTRAP_CLIENT_LIST FAR * LPXTRAP_CLIENT_LIST;

how to define this structure in c# .net. and how to use the function which is using the structure.

i have defined the structure as

public struct XTRAP_CLIENT_LIST
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string prnNetAdd;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string hostAddress;
public XTYPE_ADDESS ClientType;
public IntPtr next;

}

But i don't know how to use use the IntPtr in my function.
Jan 23 '07 #1
1 1149
radcaesar
759 Expert 512MB
Try like this,

IntPtr handle = this.ServiceHandle;

myServiceStatus.currentState = (int)State.SERVICE_START_PENDING; //0x00000002
myServiceStatus.checkPoint = 1;
myServiceStatus.waitHint = 5000;
SetServiceStatus(handle, ref myServiceStatus);


Hello,

i want to use the unmanaged code in CSharp.

the structure defined in the cpp dll is

typedef struct XTRAP_CLIENT_LIST
{
char prnNetAdd[100];
char hostAddress[100];
XTYPE_ADDESS ClientType;
struct XTRAP_CLIENT_LIST* next;
} XTRAP_CLIENT_LIST;

typedef XTRAP_CLIENT_LIST FAR * LPXTRAP_CLIENT_LIST;

how to define this structure in c# .net. and how to use the function which is using the structure.

i have defined the structure as

public struct XTRAP_CLIENT_LIST
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string prnNetAdd;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string hostAddress;
public XTYPE_ADDESS ClientType;
public IntPtr next;

}

But i don't know how to use use the IntPtr in my function.
Jan 23 '07 #2

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

Similar topics

2
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#...
3
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
16
by: pkoniusz | last post by:
Hello everybody, Been just thinking how actually one could convert the following unmanaged code to the managed C++: struct JustAnExample { char value1; int value2; // etc ....
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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
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...

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.