Solved

using twain scanner under delphi xe

Posted on 2013-01-28
6
1,625 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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