Solved

using twain scanner under delphi xe

Posted on 2013-01-28
6
1,541 Views
Last Modified: 2013-02-05
Hi, I was using the free component multitwain's  function called TWAIN_AcquireNative(0, 0) and it was working fine under delphi 5 but with delphi XE, the same code give an access violation 00000000.    

I have attached the component even though I pretty sure there's no way it can be fixed.

I think I would probably need a new component.   My goal is to be able to tell windows to open the scan document dialog and then when it's done, I need to specify via my software the name of the file and where to save it based on what was scanned.  

I'm not used to interact with scanners, I would need someone to point me in the right direction.
multitwain.pas
0
Comment
Question by:Buropro-Citation
  • 4
6 Comments
 
LVL 21

Expert Comment

by:developmentguru
ID: 38827757
Right off the top of my head, you will need to change PChar to PAnsiChar.  In Delphi 5 PChar was a pointer to an ANSI based character string.  Newer versions of Delphi use a wide char for a normal character.  Once you have changed the declarations of the interface functions, you will need to make sure to assign your strings to an ansistring type of string, or use the compiler settings to limit the entire program to using ansi strings.
0
 

Author Comment

by:Buropro-Citation
ID: 38831638
Hi have replaced all pchar for pansichar but I'm not sure what you mean by changing strings to ansistrings since there is no strings variable in the multitwain.pas

Changing only pchar to pansichar didn't resolved the problem, I'll need more informations about the second part of the solution.
0
 

Author Comment

by:Buropro-Citation
ID: 38831706
I have found something interesting, there is a eztwain.c which is used and when I go step by step, the error actually occurs right here (I don't see why though):

HWND CreateProxyWindow(void)
{
      HWND hwnd;
      hwnd = CreateWindow("STATIC",                                    // class
                                    "Acquire Proxy",                        // title
                                    WS_POPUPWINDOW | WS_VISIBLE,      // style
                                    CW_USEDEFAULT, CW_USEDEFAULT,      // x, y
                                    CW_USEDEFAULT, CW_USEDEFAULT,      // width, height
                                    HWND_DESKTOP,                              // parent window
                                    NULL,                                          // hmenu
                                    hinstLib,                                    // hinst
                                    NULL);                                          // lpvparam
      return hwnd;
} // CreateProxyWindow
Eztwain.c
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 25

Expert Comment

by:Sinisa Vuk
ID: 38833513
0
 

Accepted Solution

by:
Buropro-Citation earned 0 total points
ID: 38839649
I have tried the mentioned solution and it didn't worked.   I have in the meantime found the cause of the problem this morning, in delphi 5 I was able to use
TWAIN_AcquireNative(0, 0); which was the suggested way of using it on the web but now I have to send the form handle like so : TWAIN_AcquireNative(form1.Handle, 0);

This is why the createwindows function was giving an error.    As to why the eztwain.c reacts differently when it is called from delphi xe will remain a mystery.

Thank you for giving some attention to this case, it's appreciated.
0
 

Author Closing Comment

by:Buropro-Citation
ID: 38854282
I have found the answer while also trying expert solutions which, even though were good suggestions, didn't solve the problem.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now