方法:
MT_RESULT MTGetAdapterInfo(const BOARD nboard,PMTADAPTER_INFO const pBoardInfo,PULONG const pLength);参数说明:
nboard :board number
pBoardInfo :pointer to MTADAPTER_INFO structure
pLength :Set by the user application, this is a pointer to the size of the given buffer
for the MTADAPTER_INFO structure.Structure定义说明:
MTADAPTER_INFO structure is defined as follows:
public struct MTADAPTER_INFO
{
ulong Status; // Status value of BOARD_OK, etc.
ulong BoardNumber; // Board index in SDK, i.e. SystemIndex
MT_VERSION FWVersion; // On board firmware version
ulong BaseAddress; // I/O base address
ulong Interrupt; // Interrupt number
ulong StartChannel; // Logical # of the 1st on board channel
ulong Channels; // Number of channels on the board
ulong Option1; // Basic Board option
// option 1
// bit 0 WAV
// bit 1 MVIP
// bit 2 Volume/Pitch
// bit 3 MF
// bit 4 Silence Compression
ulong Option2; // Extended Board option
// option 2
// bit 0 Caller ID
// bit 1 Conference
// bit 2 Call Logging
// bit 4 FAX
// bit 6 Pulse detection
ulong Digirate; // Digitizing rate
ulong Bandwidth; // Channel bandwidth
ulong PCISlot;
ulong PCIBusNumber; ulong BoardType; // Board Type of DUAL_T1_PASSIVE_HI_CARD, etc. UCHAR BusType; // MUX_H100, MUX_MVIP, or MUX_NONE
UCHAR MasterMode; // Board Master Mode of the following:
// 0 slave board
// 1 MVIP master, or H100 Master A
// 2 H100 Master B
UCHAR MasterClock; // Master clock source reference value
// of CLOCK_SOURCE_OSC, and etc.
UCHAR Sec8kNetrefClock; // MVIP Sec8K or H100 Netref clock output
// 0 Disabled, output tri-stated
// 1, 3 - 4 Type of clock reference of
// CLOCK_SOURCE_OSC, etc.
UCHAR NumSummations; // Number of summation resource on board, if any
UCHAR StartSummation; // Index of the first on board summation resource
UCHAR NumAudios; // Number of audio jack resource on board, if any
UCHAR StartAudio; // Index of the first on board audio jack resource
UCHAR TDMSignaling; // CT TDM bus signaling: 0 for u-law, 1 for A-law
UCHAR ConfigurationId; // Adapter Configuration Index (i.e. SwitchIndex)
UCHAR res[2];
MT_VERSION FWVersionExpected; // Expected on board firmware version
}函数返回值:
MT_RET_OK No error
MT_RET_INVALID_PARAM Invalid argument passed to function
MT_RET_INVALID_BOARD Board number is out of range
MT_RET_NOT_AVAILABLE Driver is not loaded
我想知道的问题是:
1,他的返回值是自定的key值(.h中的定义之一:#define MT_RET_INVALID_PARAM 0xE0002012L),我应该用什么托管类型来与之对应?
2,他所有的自定义类型我都必须建立与之对应的托管版本么?
3,”a pointer to the size of the given buffer“ 这个buffer我应该用什么托管类型代替?
4,哪里有专题的非托管到托管类型包装的的讨论?
谢谢
MT_RESULT MTGetAdapterInfo(const BOARD nboard,PMTADAPTER_INFO const pBoardInfo,PULONG const pLength);参数说明:
nboard :board number
pBoardInfo :pointer to MTADAPTER_INFO structure
pLength :Set by the user application, this is a pointer to the size of the given buffer
for the MTADAPTER_INFO structure.Structure定义说明:
MTADAPTER_INFO structure is defined as follows:
public struct MTADAPTER_INFO
{
ulong Status; // Status value of BOARD_OK, etc.
ulong BoardNumber; // Board index in SDK, i.e. SystemIndex
MT_VERSION FWVersion; // On board firmware version
ulong BaseAddress; // I/O base address
ulong Interrupt; // Interrupt number
ulong StartChannel; // Logical # of the 1st on board channel
ulong Channels; // Number of channels on the board
ulong Option1; // Basic Board option
// option 1
// bit 0 WAV
// bit 1 MVIP
// bit 2 Volume/Pitch
// bit 3 MF
// bit 4 Silence Compression
ulong Option2; // Extended Board option
// option 2
// bit 0 Caller ID
// bit 1 Conference
// bit 2 Call Logging
// bit 4 FAX
// bit 6 Pulse detection
ulong Digirate; // Digitizing rate
ulong Bandwidth; // Channel bandwidth
ulong PCISlot;
ulong PCIBusNumber; ulong BoardType; // Board Type of DUAL_T1_PASSIVE_HI_CARD, etc. UCHAR BusType; // MUX_H100, MUX_MVIP, or MUX_NONE
UCHAR MasterMode; // Board Master Mode of the following:
// 0 slave board
// 1 MVIP master, or H100 Master A
// 2 H100 Master B
UCHAR MasterClock; // Master clock source reference value
// of CLOCK_SOURCE_OSC, and etc.
UCHAR Sec8kNetrefClock; // MVIP Sec8K or H100 Netref clock output
// 0 Disabled, output tri-stated
// 1, 3 - 4 Type of clock reference of
// CLOCK_SOURCE_OSC, etc.
UCHAR NumSummations; // Number of summation resource on board, if any
UCHAR StartSummation; // Index of the first on board summation resource
UCHAR NumAudios; // Number of audio jack resource on board, if any
UCHAR StartAudio; // Index of the first on board audio jack resource
UCHAR TDMSignaling; // CT TDM bus signaling: 0 for u-law, 1 for A-law
UCHAR ConfigurationId; // Adapter Configuration Index (i.e. SwitchIndex)
UCHAR res[2];
MT_VERSION FWVersionExpected; // Expected on board firmware version
}函数返回值:
MT_RET_OK No error
MT_RET_INVALID_PARAM Invalid argument passed to function
MT_RET_INVALID_BOARD Board number is out of range
MT_RET_NOT_AVAILABLE Driver is not loaded
我想知道的问题是:
1,他的返回值是自定的key值(.h中的定义之一:#define MT_RET_INVALID_PARAM 0xE0002012L),我应该用什么托管类型来与之对应?
2,他所有的自定义类型我都必须建立与之对应的托管版本么?
3,”a pointer to the size of the given buffer“ 这个buffer我应该用什么托管类型代替?
4,哪里有专题的非托管到托管类型包装的的讨论?
谢谢
解决方案 »
- c#combombox中显示时间的格式问题
- 微软MSDN Webcast系列视频教程集锦整理
- C# winform中怎样把TextBox中值显示在DataGrid中指定的一列
- C# 中如何动态创建方法中的参数以及函数中的变量。
- 如何获得当前程序使用的物理内存的大小!请高手指点!
- 求段代码,简单
- 怎样把DataGridView显示的文本导出到Excel文件中(winform)?
- 怎样实现这几个功能2(c#windows应用程序)?
- 请教bmp图片添加调色板的问题
- C# ORACLE 存储过程
- 求助visual studio 2005(winform)textbox的问题
- 用C#2.0开发WINDOWS应用程序,如何将修改后的数据更新到ACCESS数据库?
不过好象仅对com:tlbimp tlbFile tlbFile :The name of any file that contains a COM type library.
简单点问:c++类型如何影射到managed c#类型
ulong: uint
UCHAR: byte
UCHAR res[2]:
[MarshalAs(UnmanagedType.LPArray, SizeConst=10)]byte[] res;
public enum MT_RESULT:long
{
MT_RET_INVALID_PARAM = 0xE0002012L,
}
这里还有其他一些windows内自己定义的数据类型,我如何使用啊:
PVOID
LARGE_INTEGER
(已经修改为managed版本,除了两个winnt 数据类型:LARGE_INTEGER PVOID):public struct MT_EVENT
{ LARGE_INTEGER TimeStamp; // In FILETIME format
public uint UserStatus; // Not used by API
public uint EventCode; // Event Code
public uint SubReason; // Event sub-reason
public uint XtraInfo; // Extra information, e.g. termination
public uint FuncCode; // Function active when this event occurred
public UInt16 Board; // Board ID
public UInt16 Channel; // Global Channel ID (GCI)
PVOID ptrBuffer; // Related play/record buffer pointer
public uint DataLength; // Byte length of data accessed (played/recorded) PVOID ptrXtraBuffer; // Pointer to xtra buffer
public uint XtraBufferLength; // Length of buffer pointed by ptrXtraBuffer
public uint XtraDataLength; // Length of data in buffer pointed by ptrXtraBuffer
public uint EventFlag; // Falgs of the following:
// bit 0x00000001: 1 - Appl created the event
// 0 - NTi DLL created the event
// bit 0x00000002: 1 - Appl allocated ptrtraBuffer
// 0 - NTi DLL allocated ptrXtraBuffer
};
简单点儿,就是IntPtr,如果不想用IntPtr,看看这个类型具体指向什么类型内容;to LARGE_INTEGER
看其字节个数,
4 bytes : int or Int32
8 bytes : Int64
还有问题:方法:
MtGetInfor(
const channel,//ulong channel number
PMTCHAN_INFO const pchannel_info,//a pointer to chan_info structure
PULONG CONST plength //a pointer to the size of the gaven buffer for the chan_info structure
)
structure:
typpedef struct chan_info
{
ulong type;
chan_ts associatedts[2] //结构数组,这玩意怎么搞?
}
typedef struct chan_ts
{
short id;
short name;
}
想知道:
1,方法里第二个参数是structure pointer,我传得是 ref structure ok?
2,structure[] 要怎么弄?
[MarshalAs(UnmanagedType.LPArray, SizeConst=2)]chan_ts[] associatedts;
数组都用MarshalAs(UnmanagedType.LPArray, SizeConst=n)这样的模式
而不用管它是什么类型的么?2上边的函数第二个参数是个pointer,最后那个参数是pionter to size of given buffer for ...
有些问题,这个pointer到底是指向buffer 还是指向buffer的size我又该给他传个啥?谢谢
我按照你的提示做,得到提示can not marshal filed associatedts of type chan_ts :this type can not be marshaled as structure filed.tell me why and how to solve it please.thks a lot....
public struct chan_info
{
public uint type;
[MarshalAs(UnmanagedType.LPArray, SizeConst=2)]
public chan_ts[] associatedts;
public chan_info( uint typevalue )
{
type = typevalue;
associatedts = new chan_ts[2];
for( int i = 0; i < 2; i++ )
associatedts[i] = new chan_ts();
}
} public struct chan_ts
{
public short id;
public short name;
}
chan_info mychan_info = new chan_info( 1 );
MessageBox.Show( mychan_info.type.ToString() );
MessageBox.Show( mychan_info.associatedts[0].ToString() );
MessageBox.Show( mychan_info.associatedts[1].ToString() );
Structure里包含还有Strucrure[] 就不能Marshal....怎么解决阿
好像c#对c-style arry的支持不很好,好像仅ByValArry有用。出问题的dll函数需要一个上边的自定义的structure的pionter 参数,
刚好,这个structure里又有structure数组我现在参考别人的做法,把这个field :stucture[]替换成等同长度[bit位]的byte
上边这个长度是
typpedef struct chan_info
{
ulong type; //32
chan_ts associatedts[2] //16*4
}
typedef struct chan_ts
{
short id; //16bit
short name; //16bit
}替换成如下:public struct chan_info
{
pubic uint type;
[MarshalAs(UnmanagedType.ByValArry,ConstSize=4)//4 byte
public byte[];
}