这几句是什么意思?

yishuihepan006 2010-10-17 07:59:30
代码如下:
private SafeFileHandle TicketPrinterHandle = null;
[DllImport("kernel32.dll", SetLastError = true)]
static extern SafeFileHandle CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile);
问题1:“SafeFileHandle”是什么类?什么叫做句柄?
问题2:“[DllImport("kernel32.dll", SetLastError = true)]
”什么意思?
问题3: static extern SafeFileHandle CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile);
中“extern”表明的方法的类型是什么?
问题4:C#中有指针“ IntPtr ”,这是干什么的?

这些代码出自票据打印类:http://www.csharpwin.com/csharpspace/9090r8371.shtml
...全文
94 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-10-17
  • 打赏
  • 举报
回复
看MSDN
using System.Runtime.InteropServices; //引用此名称空间
//使用DllImportAttribute特性来引入api函数
[DllImport("kernel32.dll")]
SetLastError 参数指示方法是否保留 Win32"上一错误"。如果未指定 SetLastError,则使用默认值 false。
说明看看API
http://msdn.microsoft.com/zh-cn/library/e59b22c5(VS.80).aspx
奋斗吧 2010-10-17
  • 打赏
  • 举报
回复
这是调用Windows API,我最近也在看,也不是很懂,,等楼下高手解答
hbgfhbgf 2010-10-17
  • 打赏
  • 举报
回复
不懂,顶下!

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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