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

Opening the DSM in a console application:"reading viola

Forums › TWAIN Classic › Opening the DSM in a console application:"reading viola

  • This topic has 5 replies, 4 voices, and was last updated 7 years, 6 months ago by ilyes.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • April 11, 2010 at 4:39 am #22600 Reply
    twainuser123
    Participant
    • Topics - 9
    • Replies - 28
    • Total Posts - 37

    Hi,

    First, sorry I am a relatively new programmer, so I do not have any experience with Windows API.
    I am using Visual C++ on Windows Vista.

    I am trying to make a non-GUI application using console windows (black box screens), but I am stuck on the part of loading the DSM, which asks me for a hWnd.
    I am wondering why the code below does not work (it compiles but I keep getting “reading access violation” messages at run-time on the address of ‘parentWindow ‘):

    HWND parentWindow = GetConsoleWindow();

    //Open the Data Source Manager
    TW_UINT16 returnCode = _DSM_Entry(&appIdentity, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, (TW_MEMREF)parentWindow);
    if ((appIdentity.SupportedGroups & DF_DSM2) == DF_DSM2)
    { //Check for DSM2 support
    }

    Thank you in advance!

    April 12, 2010 at 1:35 pm #25240 Reply
    jimwatters
    Participant
    • Topics - 2
    • Replies - 72
    • Total Posts - 74

    The last parameter for MSG_OPENDSM on Windows is a pointer to a windows handle.

    TW_UINT16 returnCode = _DSM_Entry(&appIdentity, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, (TW_MEMREF)&parentWindow);

    Jim Watters

    April 13, 2010 at 6:00 am #25241 Reply
    twainuser123
    Participant
    • Topics - 9
    • Replies - 28
    • Total Posts - 37

    I knew it was something simple.
    Thanks for your help! 😛

    One more question. How come this code to load a data source does not work? ‘returnCode’ is set to 1 when I run this code:
    (appIdentity was defined before this code is called)

    //The current TWAIN source we are looking at
    TW_IDENTITY curSource;
    //We call DSM_Entry to give us the next scanner Source
    returnCode = _DSM_Entry(&appIdentity, 0, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, (TW_MEMREF)&curSource);
    April 13, 2010 at 1:01 pm #25242 Reply
    jimwatters
    Participant
    • Topics - 2
    • Replies - 72
    • Total Posts - 74

    Two things you can do to track down what is happening:

    Enabling the DSM log file can help.
    http://www.twainforum.org/viewtopic.php?t=4138

    Get the Condition Code after a failure.

      TW_STATUS status;
    memset(&status, 0, sizeof(TW_STATUS));
    TW_UINT16 twrc = _DSM_Entry( &m_MyInfo, _pdestID, DG_CONTROL, DAT_STATUS, MSG_GET, (TW_MEMREF)&status);

    Jim Watters

    July 3, 2012 at 10:04 am #25243 Reply
    sureshkallem
    Participant
    • Topics - 1
    • Replies - 7
    • Total Posts - 8

    hi,

    I created console application by twain dll, by using this application I can able to read/scan the images but control not coming back to console application from twain GUI once scanning has been done.
    Please help me on the same

    August 13, 2013 at 7:51 am #25244 Reply
    ilyes
    Participant
    • Topics - 0
    • Replies - 1
    • Total Posts - 1

    Hello,
    I try to develop a Twain console application with visual studio (c++).
    Can you help me please?

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Reply #25243 in Opening the DSM in a console application:"reading viola
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

  • Scanner starts transfer when console gets closed (CITRIX)
  • Kodak RFS 3600
  • Didn’t save enough file scan
  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • 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.