Delphi中的 type PDevice_Set = ^TDevice_Set (注:TDevice_Set为结构)上述Delphi中的这行代码如何转换成C#语言的相应代码,谢谢
解决方案 »
- 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
- 用 datagridview 绑定并更新的灵活性问题,
- GDI+如何实现一张纸牌从背面翻转到正面?
- VS2005里面这些代码为什么会有出错提示?怎么改?
- 没有访问目录xxxx的权限
- 子类如何强制转换成父类??
- 在c#里怎么改变ComboBox的外观,
- LogonUser + CreateProcessAsUser 在windows服务中调用 外部exe程序 ,求高人指点
- 装箱问题(初学)
- ListView中修改SubItem的Text,为什么界面不更新显示?
- 请问,这个功能,怎么写?
- C#开发的windows服务在xp下运行都是正常的,为什么在windows2003下可以安装,但启动服务时总是弹出“错误1053”服务没有及时响应启动或控制请求
id : Integer;
_name : Array[0..31] of Char;
username : Array[0..31] of Char;
userpass : Array[0..15] of Char;
ip : Array[0..15] of Char;
port : Cardinal;
channel_count : Byte;
start_channel : Byte;
device_type : Byte;
end;
[System.Runtime.InteropServices.StructLayout
(LayoutKind.Explicit)]
public struct TDevice_set
{
[System.Runtime.InteropServices.FieldOffset(0)]
public int32 id; [System.Runtime.InteropServices.FieldOffset(4)]
unsafe public fixed byte_name[32]; System.Runtime.InteropServices.FieldOffset(36)]
unsafe public fixed byte username [32]; System.Runtime.InteropServices.FieldOffset(48)]
unsafe public fixed byte userpass[16]; System.Runtime.InteropServices.FieldOffset(64)]
unsafe public fixed byte ip[16]; [System.Runtime.InteropServices.FieldOffset(80)]
public uint32 port; [System.Runtime.InteropServices.FieldOffset(84)]
public byte channel_count; ......省略了
}2.PDevice_Set = ^TDevice_Set 在c#中你不需要定义了直接使用TDevice_set* 来定义变量,记得项目中药运行不安全代码
id : Integer;
_name : Array[0..31] of Char;
username : Array[0..31] of Char;
userpass : Array[0..15] of Char;
ip : Array[0..15] of Char;
port : Cardinal;
channel_count : Byte;
start_channel : Byte;
device_type : Byte;
end;
type PDevice_Set = ^TDevice_Set;function Devicelist_Callback(aset: PDevice_set;pksize:integer): Boolean;
var
device : PDevice_Set;
begin
new(device);
if sizeof(TDevice_set)<pksize then
pksize := sizeof(TDevice_set);
move(aset^, device^, sizeof(TDevice_set));
devicelist.Add(device);
result := True;
end;如何把上述代码翻译成对应的C#代码