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

Marshalling issue

The following is my data structure in unmanaged code...
Expand|Select|Wrap|Line Numbers
  1. typedef struct {
  2.         USHORT   flash_char;            /* flash char (default &)         */
  3.         USHORT   flash_time;            /* flash time (ms)                */
  4.  
  5.         USHORT   reserved[3];
  6. } MT_PSTN, *PMT_PSTN;
  7.  
(this is function in unmanaged code that i have to call..)
Expand|Select|Wrap|Line Numbers
  1. _DLLIMPEXPORT MT_RESULT CALLING_CONVENTION
  2. MTGetPSTNParams(
  3.     const CHANNEL       nChannel,
  4.     PMT_PSTN const      pRegs,
  5.     PULONG const        pLength
  6.     );
  7.  
Can anybody tell me the corresponing stucture i could use in my managed c# code.. im currently using the following structure.. im going wrong somewhere..
Expand|Select|Wrap|Line Numbers
  1. [StructLayout(LayoutKind.Sequential)]
  2.         public struct PMT_PSTN
  3.         {
  4.             public ushort flash_char;            /* flash char (default &)         */
  5.             public ushort flash_time;            /* flash time (ms)                */
  6.  
  7.             [MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
  8.             public ushort[] reserved;
  9.         } 
  10.  
(corresponding function declaration..)
Expand|Select|Wrap|Line Numbers
  1. [DllImport("ntidrv.dll", CallingConvention = CallingConvention.StdCall)]
  2.         private static extern ReturnCodes MTGetPSTNParams(short nChannel, [Out, MarshalAs(UnmanagedType.LPStruct)]PMT_PSTN pRegs, uint pLength);
Sep 11 '08 #1
0 898

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

Similar topics

3
by: PHil Coveney | last post by:
Hello, I am having difficulty marshalling structures when calling DeviceIoControl. I am importing this Win32 function as static extern int DeviceIoControl (int hDevice, int...
4
by: Animesh | last post by:
Hi All, I don't know whethher this is possible or not. This is the result of a bad design problem. Here I go; I have a structure like this: typedef struct _s_index_entry { char *doc_id;...
3
by: Jerry Houston | last post by:
In a winform application, I use worker threads to perform asynchronous tasks (e.g., mail merge with Word). The thread procs need to gather some user options from controls in the UI, and I know...
3
by: awk | last post by:
Hi All I have a com dll written in VB6 (it's a User Function Library for my crystal reports - this allows me to write custom functions for Crystal which can be applied in Crystal formulas - none...
2
by: Howard Kaikow | last post by:
I've got the following in a VB 6 project: Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long...
0
by: swartzbill2000 | last post by:
I am familiar with the VB6/VC6/ATL way of marshalling an incoming interface via New (VB), and then marshalling an outgoing interface with some form of Advise. To me it looks like .Net has...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
2
by: RJ Lohan | last post by:
Howdy, I have a legacy DLL for which I have a problem marshalling a parameter type of char**. The function header (C++) is as so; extern "C" __declspec(dllexport) int __stdcall...
2
by: calenlas | last post by:
Hi all, I'm taking my first steps into C# <--C++ DLL Interop and unfortunately I've run into (what seems to be) a very complicated case as my first task. Perhaps someone here can help me. I...
0
by: santoshdarekar | last post by:
HI, I have some code which I am reverse engineering. Here is one module which is used as calculation madule and marshalling is used in it. But, still there is performance issue as the CPU time the...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.