关于“设备描述表句柄”????
日期:2007-04-08 荐:
关于“设备描述表句柄”????我们专业从事指纹识别技术,今天一个客户在VB.NET里读取指纹图像。遇到显示不了指纹图像的故障,但从指纹仪里读取的指纹图像可以保存和比对。我们的示例程序在VB编写的(如下):Private Sub ZKFPEngX1_OnImageReceived(AImageValid As Boolean) ZKFPEngX1.PrintImageAt hDC, FrameCommands.Width 6, FrameCommands.Top, ZKFPEngX1.ImageWidth, ZKFPEngX1.ImageHeightEnd Sub或者:Private Sub ZKFPEngX1_OnImageReceived(AImageValid As Boolean) ZKFPEngX1.PrintImageAt hDC, 100, 200, 200, 200 End Sub或者:Private Sub ZKFPEngX1_OnImageReceived(AImageValid As Boolean) ZKFPEngX1.PrintImageAt 100, 100, 200, 200, 200 End Sub示例程序VB里编译执行没有任何问题。在VB.NET里语句如下: Private Sub AxZKFPEngX1_OnImageReceived(ByVal sender As Object, ByVal e As AxZKFPEngXControl.IZKFPEngXEvents_OnImageReceivedEvent) Handles AxZKFPEngX1.OnImageReceived ZKFPEngX1.PrintImageAt 100, 100, 200, 200, 200 End Sub在VB.NET里无法显示指纹图像。开发包函数调用说明: Sub PrintImageAt(HDC As OLE_HANDLE, X As Long, Y As Long, aWidth As Long, aHeight As Long)在由(x,y)指定的位置上按照(aWidth, aHeight)指定的大小显示指纹图像,HDC表示要显示指纹的窗口的设备描述表句柄我个人认为在VB.NET不知道要如何表示HDC这个“显示指纹图像的窗口的设备描述表句柄”小弟初涉编程,请各位高手指教。谢谢!Sub PrintImageAt(HDC As OLE_HANDLE, X As Long, Y As Long, aWidth As Long, aHeight As Long)到了NET,上函数的声明是: Sub PrintImageAt(HDC As OLE_HANDLE, X As int32, Y As int32, aWidth As int32, aHeight As int32)NET中的Long是int64.这些不知你注意到了没有。如果还是不行的话,那得注意HDC的封送。HDC是一个结构吧?参考封送结构。只是这方面我没多大接触,也同样的不大理解。这是一个端口打印有关声明,你参考一下: <StructLayout(LayoutKind.Sequential)> _ Public Structure DCB Public DCBlength As Int32 Public BaudRate As Int32 Public fBitFields As Int32 Public wReserved As Int16 Public XonLim As Int16 Public XoffLim As Int16 Public ByteSize As Byte Public Parity As Byte Public StopBits As Byte Public XonChar As Byte Public XoffChar As Byte Public ErrorChar As Byte Public EofChar As Byte Public EvtChar As Byte Public wReserved1 As Int16 End Structure <StructLayout(LayoutKind.Sequential)> _ Public Structure COMMTIMEOUTS Public ReadIntervalTimeout As Int32 Public ReadTotalTimeoutMultiplier As Int32 Public ReadTotalTimeoutConstant As Int32 Public WriteTotalTimeoutMultiplier As Int32 Public WriteTotalTimeoutConstant As Int32 End Structure Public Const GENERIC_READ As Int32 = &H80000000 Public Const GENERIC_WRITE As Int32 = &H40000000 Public Const OPEN_EXISTING As Int32 = 3 Public Const FILE_ATTRIBUTE_NORMAL As Int32 = &H80 Public Const NOPARITY As Int32 = 0 Public Const ONESTOPBIT As Int32 = 0 <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function CreateFile _ (ByVal lpFileName As String, ByVal dwDesiredAccess As Int32, _ ByVal dwShareMode As Int32, ByVal lpSecurityAttributes As IntPtr, _ ByVal dwCreationDisposition As Int32, ByVal dwFlagsAndAttributes As Int32, _ ByVal hTemplateFile As IntPtr) As IntPtr End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function GetCommState(ByVal nCid As IntPtr, _ ByRef lpDCB As DCB) As Boolean End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function SetCommState(ByVal nCid As IntPtr, _ ByRef lpDCB As DCB) As Boolean End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function GetCommTimeouts(ByVal hFile As IntPtr, _ ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function SetCommTimeouts(ByVal hFile As IntPtr, _ ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _
Public Function WriteFile(ByVal hFile As IntPtr, _ ByVal lpBuffer As Byte(), ByVal nNumberOfBytesToWrite As Int32, _ ByRef lpNumberOfBytesWritten As Int32, ByVal lpOverlapped As IntPtr) As Boolean End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function ReadFile(ByVal hFile As IntPtr, _ ByVal lpBuffer As Byte(), ByVal nNumberOfBytesToRead As Int32, _ ByRef lpNumberOfBytesRead As Int32, ByVal lpOverlapped As IntPtr) As Boolean End Function <DllImport("kernel32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)> _ Public Function CloseHandle(ByVal hObject As IntPtr) As Boolean End Function哪位可以帮助编写一段给我吗?谢谢!没有一个人帮得了我吗?
标签: