473,382 Members | 1,329 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,382 software developers and data experts.

using Marshal.PtrToStructure in c#

I have following two structures in
vc++ and i want to convert it into c#
typedef struct
{
ULONG CallRef ;
ULONG CallSource ;
ULONG CallState ;
ULONG CallTrunk ;
ULONG CallDuration ;
ULONG Layer1Coding ;
ULONG Cause ;
MT_CC_CHANNEL_ID ChannelId ;
MT_CC_PARTY_NUMBER CallerNumber ;
MT_CC_PARTY_SUBADDR CallerSubAddr ;
MT_CC_PARTY_NUMBER CalledNumber ;
MT_CC_PARTY_SUBADDR CalledSubAddr ;
MT_CC_PARTY_NUMBER ConnectedNumber ;
MT_CC_PARTY_SUBADDR ConnectedSubAddr ;
MT_CC_PARTY_NUMBER RedirectingNumber ;
MT_CC_CALL_IDENTITY CallIdentity ;
} MT_CC_CALL_INFO;
typedef struct _MT_EVENT {
LARGE_INTEGER TimeStamp;
ULONG UserStatus;
ULONG EventCode;
ULONG SubReason;
ULONG XtraInfo;
ULONG FuncCode;
USHORT Board;
USHORT Channel;
PVOID ptrBuffer; // Related play/record buffer pointer
ULONG DataLength;
PVOID ptrXtraBuffer;
ULONG XtraBufferLength;
ULONG XtraDataLength;
ULONG EventFlag;
} MT_EVENT, *PMT_EVENT;

MT_EVENT event;

MT_CC_CALL_INFO *pCallInfo = (MT_CC_CALL_INFO *)event.ptrBuffer;

How to do struct type casting using Marshal.PtrToStructure or
Marshal.StructureToPtr in c#?
Sep 12 '07 #1
0 1387

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

Similar topics

4
by: Umesh | last post by:
Hi all I am trying to change the printer(like paper source ,etc) setting in C#. But i am unable to do it. I am not sure how to do it. should i have to use WIN API like Openprinter , getprinter ,...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: William Stacey | last post by:
The following code works, but I can't figure out why. I take a struct with two members, a single byte and byte. I then marshal the whole struct to a byte. I create a new struct (without init'ing...
10
by: Joe M | last post by:
I was wondering if someone could lend me a hand with a C# problem I am having I am trying to use the “setPrinter” api to change the duplex setting (under printing preferences on printer...
1
by: Ken Allen | last post by:
The documentation is not clear on the exact behaviour of the Marshal.PtrToStructure method and whether it copies the contents of the IntPtr region to a new managed object or whether it creates the...
2
by: Einar Hst | last post by:
Hi, I'm reading data from a tape device using p/invoke. It's working pretty well, but when I'm trying to get data about the tape device, I'm doing something wrong. I believe it has something to...
2
by: John | last post by:
public const int FRAME_LENGTH=144; public class FRAME_T { public byte Block = new byte; } public void MyDataHandler(IntPtr appContext, IntPtr data) FRAME_T frame = new FRAME_T();...
3
by: Raj | last post by:
I want to pass a C structure from a windows server to the C# client using the Sockets. Will there be requirements to cast the data types in the C# client?
2
by: =?Utf-8?B?dmxhZGltaXI=?= | last post by:
Hi, i have big subsystem written in old C and published by dll (and lib). Dll functions do: 1) allocate global memory for internal structures 2) controls dll subsystem (communicate by sockets,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.