C#问题

hypozhu 2009-03-17 09:32:22
各位前辈 麻烦看下 下面是我写的C#代码 过程就是这样的 需要两次调用ETEnum函数 第一次调用时第一个参数需要给一个空值 小弟刚刚学习写程序不知如何实现 各位大侠多帮忙啊 跪求!
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace et199dll
{
class Program
{
[StructLayout(LayoutKind.Sequential)]
unsafe public struct ET_CONTEXT
{
ulong dwIndex;
ulong dwVersion;
IntPtr hLock;
ulong wAtrLen;
ulong dwCustomer;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
byte [] reserve;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
byte [] bAtr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
byte [] bID;

}


[DllImport("ET199_32.dll")]
unsafe public static extern ulong ETEnum(ref ET_CONTEXT pETContextList,ref ulong pdwDeviceCount);
[DllImport("ET199_32.dll")]
unsafe public static extern ulong ETOpen(ref ET_CONTEXT pETCtx);
//[DllImport("ET199_32.dll")]


unsafe static void Main(string[] args)
{

ulong dwRet;
ulong dwCount = 0;
ET_CONTEXT ContextList = new ET_CONTEXT();
dwRet = ETEnum(null, ref dwCount);


dwRet = ETEnum(ref ContextList, ref dwCount);



Console.WriteLine("{0}{1}","Find ET199: ",dwCount);
Console.ReadKey();
}

}
}
...全文
49 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunshine_anycall 2009-03-17
  • 打赏
  • 举报
回复
用null不行吗?
报什么错?
hypozhu 2009-03-17
  • 打赏
  • 举报
回复
就是main函数中的 dwRet = ETEnum(null, ref dwCount); //第一次调用

13,192

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 分析与设计
社区管理员
  • 分析与设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧