Home › Forums › TWAIN Classic › Opening the DSM in a console application:"reading viola
- This topic has 5 replies, 4 voices, and was last updated 10 years, 7 months ago by ilyes.
- AuthorPosts
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!
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
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);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=4138Get 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
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 sameHello,
I try to develop a Twain console application with visual studio (c++).
Can you help me please?- AuthorPosts