TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Twain Capabilities – Using CAP_SUPPORTEDCAPS

Forums › TWAIN Classic › Twain Capabilities – Using CAP_SUPPORTEDCAPS

  • This topic has 1 reply, 1 voice, and was last updated 8 years, 5 months ago by si_ben.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 18, 2012 at 7:36 pm #22754 Reply
    si_ben
    Participant
    • Topics - 7
    • Replies - 22
    • Total Posts - 29

    Hey there, new to Twain Development.

    I have been working on a project for work for a few months. Created this awesome class to do scanning with WIA and found that most of our customers use Scanner devices that use TWAIN.

    I have attempted to futz around with twain. I got selecting a source and acquiring an image converted from C# TwainGUI example. I code in Visual Basic so converted most of it. Now what I’m trying to do is create an application that lists the capabilities of the Source. I guess I still am not fully understanding how to access the TW_ARRAY.

    '// This is my structure for Capability
    _
    Friend Class TwCapability
    'Declare Vars
    Public Cap As Short
    Public ConType As Short
    Public Handle As IntPtr
    ' TW_CAPABILITY
    Public Sub New(ByVal cap__1 As TwCap)
    Cap = CShort(cap__1)
    ConType = -1
    End Sub
    Public Sub New(ByVal cap__1 As TwCap, ByVal sval As Short)
    Cap = CShort(cap__1)
    ConType = CShort(TwOn.One)
    Handle = Twain.GlobalAlloc(&H42, 6)
    Dim pv As IntPtr = Twain.GlobalLock(Handle)
    Marshal.WriteInt16(pv, 0, CShort(TwType.Int16))
    Marshal.WriteInt32(pv, 2, CInt(sval))
    Twain.GlobalUnlock(Handle)
    End Sub
    Protected Overrides Sub Finalize()
    Try
    If Handle <> IntPtr.Zero Then
    Twain.GlobalFree(Handle)
    End If
    Finally
    MyBase.Finalize()
    End Try
    End Sub
    End Class

    '// This is my Enum
    Friend Enum TwCap As Short
    ' CAP_XFERCOUNT
    XferCount = &H1
    SupportedCaps = &H1005 '// This is what I added
    ' ICAP_...
    ICompression = &H100
    IPixelType = &H101
    IUnits = &H102
    IXferMech = &H103
    End Enum

    '// This is my function
    Public Function Load_DS_SupportedCapabilities()
    Dim rc As TwRC
    Dim cc As TwCC
    Dim cap As New TwCapability(TwCap.SupportedCaps)
    rc = DScap(appid, srcds, TwDG.Control, TwOn.Range, TwMSG.Get, cap)
    If rc <> TwRC.Success Then
    cc = DScap(appid, srcds, TwDG.Control, TwOn.Range, TwMSG.Get, cap)
    If (cc <> TwCC.Success) Then
    Select Case cc.ToString()
    Case Is = "Bummer"
    MessageBox.Show("General Failure: Unload Source Immediately!")
    Case Else
    MessageBox.Show("Unkown Error: Unload Source Immediately!")
    End Select
    End If
    Else

    End If
    Return "Success"
    End Function

    I attempt calling this function when I am in State 4. I have just been really lost and I feel like I am getting nowhere after 2 weeks.

    Any comments or suggestions would be really helpful. Even pointing me in the right direction in the Spec Book (PDF) would be nice. Thank you.

    August 1, 2012 at 4:46 pm #25619 Reply
    si_ben
    Participant
    • Topics - 7
    • Replies - 22
    • Total Posts - 29

    View This Post:>

    viewtopic.php?f=2&t=10148

    Issue been resolved… Questions Post on that Thread

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Twain Capabilities – Using CAP_SUPPORTEDCAPS
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.