Hello, I am a novice c++ programmer trying to call the TWAIN dll. They have an example in thier specification, but I can't get it to work. I either get Error 1 error C2197: 'int (__stdcall *)(void)' : too many arguments for callrc=(*pProc)(&twApp, 0, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, Wrapper::Caller); (the "TWAIN" way)
or Error 1 error C2197: 'FARPROC' : too many arguments for callrc=pProc(&twApp, 0, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, Wrapper::Caller);
when I tried to call it the way I found described by microsoft. I don't know what I am doing wrong.
OK, I've made some progress with help from Jim Watters. It seems I needed the twain.h file. Copying and pasting the needed constants and structures isn't enough. Now I have a new problem.
The call now fails with a message in the calling application (VB.NET) Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Do I have to do something if I am calling unmanaged code from managed code? A VB.NET app is calling the C++ function which is failing.
I tried calling it 4 different ways with the same error. The proc tries to write a number to twApp.Id so I assume that is what's causing the problem. Thanks for any assistance.
After more research it may be an issue of having unmanaged code write to a structure allocated by managed code. Can anyone point a beginning C++ programmer somewhere to get assistance?