Hello
I am making an application to scan with TWAIN. I can get to state 4 OK, and scan with the UI. But I need to hide the UI. When I do this the scanner does nothing. I believe it needs some capabilities set (like height and width). So I try to get the physical height and width so I can set them. Herein lies the problem. I get 18874402 back for the physical height and width. (neither can I get the units). I get RC=SUCCESS. I don't think it could be a signed/unsigned issue because what boundary is at 18 million +/- with whatever units? I tried some other code I found but that returns 0. I can't figure out what I am doing wrong. Here's the code:
And here's how I call it:Code:Private Function GetOneValue(ByVal twCapability As twsCapability) As String Dim rc As twRC Dim strTemp As String Dim twOneValue As TW_ONEVALUE rc = DS_Capability(mtwApp, mtwSource, twDG.Control, twDAT.Capability, twMSG.Get, twCapability) If rc = twRC.Success Then strTemp = vbNullString Select Case twCapability.ConType Case twContainerTyoe.One twOneValue = New TW_ONEVALUE Marshal.PtrToStructure(twCapability.Handle, twOneValue) strTemp = CType(twOneValue.Item, String) Case Else MsgBox("Error, one value expected; " & twCapability.ConType & " returned.") End Select Marshal.FreeHGlobal(twCapability.Handle) Return strTemp Else ErrorStatus() Return vbNullString End If End Function
If I can get it to work I will post the class here for others to use. Any help is appreciated, thanks for looking.Code:twCapability = New twsCapability With twCapability .Cap = twCap.IPhysicalWidth .ConType = twContainerTyoe.One 'TWON_DONTCARE16 '.Handle = Nothing End With strWidth = GetOneValue(twCapability)




Reply With Quote