Sr. Antonio - ScanCAPI.h

Sr. Antonio - ScanCAPI.h

Postby MGA » Wed Oct 07, 2009 6:06 pm

Estou seguindo este exemplo para usar o SCANNER do MC1000

viewtopic.php?f=7&t=833&p=3164&hilit=scancapi.h#p3164


La forma correcta de generar el fichero LIB es:

1. Crear el fichero DEF a partir desde la DLL:

impdef.exe scnapi32.def scnapi32.dll

2. Crear la LIB a partir del fichero DEF:

lib.exe /def:scnapi32.def /machine:arm /out:scnapi32.lib

porem me ocorre o erro:

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for Pocket PC - January 2009 Harbour development power │▄
│ (c) FiveTech Software, 1993-2009 for Microsoft Windows Pocket PC │█
└────────────────────────────────────────────────────────────────────────────┘█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
Harbour 1.0.1dev Intl. (Rev. 9361)
Copyright (c) 1999-2008, http://www.harbour-project.org/
Compiling 'bar.prg' and generating preprocessed output to 'bar.ppo'...
Lines 1792, Functions/Procedures 5
Generating C source output to 'bar.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.

bar.c
bar.prg(24) : fatal error C1083: Cannot open include file: 'ScanCAPI.h': No such
file or directory
LINK : fatal error LNK1181: cannot open input file 'bar.obj'
* Linking errors *
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Sr. Antonio - ScanCAPI.h

Postby Antonio Linares » Thu Oct 08, 2009 10:01 pm

SGS,

Estamos intentando localizar el fichero scancapi.h para proporcionártelo :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sr. Antonio - ScanCAPI.h

Postby Antonio Linares » Sat Oct 10, 2009 9:08 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sr. Antonio - ScanCAPI.h

Postby Antonio Linares » Sat Oct 10, 2009 9:41 pm

Y aqui un ejemplo proporcionado amablemente por Osvaldo Ramirez:
Code: Select all  Expand view

#include "fwce.ch"
#include "hbclass.ch"
#include "Directry.ch"

#define crlf chr(13)+chr(10)
#define CRLF chr(13)+chr(10)
#define CR chr(13)

#pragma comment (lib,"scnapi32")

FUNCTION Main()
* begin

 PRIVATE oWnd
 PRIVATE cLog := ""
 PRIVATE nCant := 1 , oCant
 PRIVATE nExist := 0
 PRIVATE oInvPC , oMsg , oMarca, oPrecio , oDes , oMsg2
 PRIVATE cBarCode := space(15) , oBarCode
 PRIVATE files_dir := "\\caja1\c\"
*  PRIVATE files_dir := "
Storage Card\"
*  PRIVATE files_dir := "
\\notebook\c\"
 PRIVATE nContador := 0 , oContador
 PRIVATE cEncargado := space(15) , oEncargado
 PRIVATE cCurDir := curdir()
 PRIVATE lUsers := .F.

 PRIVATE dFecha := date() , oFecha
 PRIVATE cHora := time() , oHora
 PRIVATE nNumInventario := 0 , oNumInventario // El no. de inventario es una varible o archivo en el sistema

 IF StillRun("
Toma-Facil++ V4.0")
   Quit
 ENDIF

/* Primero Pedimos la fecha y hora del sistema.

 DEFINE WINDOW oWnd TITLE "
Sistema de Toma de Inventario v12.15"

 @ 1.0,02 SAY "
Fecha :" SIZE 60, 18
 @ 1.0,09 GET oFecha  VAR dFecha picture "
@D" SIZE 70, 20
 @ 2.5,02 SAY "
Hora  :" SIZE 60, 18
 @ 2.5,10 GET oHora    VAR cHora picture "
99:99:99" SIZE 70 , 20
 @ 3.8,02 SAY "
#-Inventario:" SIZE 75, 18
 @ 3.98,11 GET oNumInventario VAR nNumInventario picture "
999999" SIZE 70, 20

 @ 12, 2 BUTTON "
Aceptar" SIZE 80, 30 ACTION oWnd:END()
 @ 12,35 BUTTON "
Cerrar App" SIZE 80, 30 ACTION oWnd:END()

 oWnd:Activate()
*/

* if file( files_dir+"
pos\datafile\users.dbf")
*   copy file (files_dir+"
pos\datafile\users.dbf") to ( "users.dbf" )
* endif

*  if file( "
users.dbf" )
*    lUsers := .T.
*    use ( "
users.dbf" ) alias USERS NEW
*    index on upper( user_id ) to ( "
users1.ntx" )
*    go top
*  endif

*  ShowKeyboard()

 DEFINE WINDOW oWnd TITLE "
Toma-Facil++ V4.0"

 @ 1.0,02 SAY "
Cantidad :" SIZE 70, 20
 @ 1.0,12 GET oCant VAR nCant picture "
99999" VALID CheckCant() SIZE 40, 20
 @ 2.3,02 SAY "
Codigo   :" SIZE 70, 20
 @ 2.5,12 GET oBarCode VAR cBarcode picture "
@!" VALID CheckBarCode() SIZE 120, 20
* @ 3.5,02 SAY "
Encargado:" SIZE 70, 20
* @ 3.9,12 GET oEncargado VAR cEncargado picture "
@!" VALID GrabaEncargado() SIZE 120, 20

 @ 6.0,02 SAY oMarca  VAR "
Marca :" SIZE 150, 20
 @ 7.3,02 SAY oPrecio VAR "
Precio Venta :" SIZE 150, 20
 @ 8.6,02 SAY oDes    VAR "
Descripcion :" SIZE 400, 20
 @ 9.9,02 SAY oInvPC  VAR "
Inventario PC :" SIZE 150, 20
 @11.2,02 SAY oMsg    VAR "
Ultimo Mensaje :" SIZE 400, 20
 @12.7,02 SAY oMsg2   VAR "
"                 SIZE 400, 20

 @ 14.6,20 SAY oContador  VAR "
Contador:" SIZE 100, 20
 @ 12, 2 BUTTON "
Terminar" SIZE 80, 30 ACTION oWnd:END()

 ACTIVATE WINDOW oWnd on Init BuildTimer( oWnd )

 IF ! empty( cLog ) // Significa que hubo activad
  IF file( files_dir+"
download\inventa.log" )
    cLog := memoread( files_dir+"
download\inventa.log" ) + cLog
  ENDIF
  memowrit( files_dir+"
download\inventa.log" , cLog )
 ENDIF

*  HideKeyboard()

RETURN NIL

procedure BuildTimer( oWnd , oInvPC )
* Begin
 Define Timer oTimer Interval 1000 Action CheckBattery() OF oWnd
 Activate Timer oTimer
return

function CheckBattery()
 If BatteryLife () < 10
  oMsg2:VarPut( "
!! Sin bateria, favor de salir y grabar su informacion.!!")
  oMsg2:refresh()
 endif
return .t.


FUNCTION CheckCant()
* begin
 LOCAL cFile , cRet , nActual := 0 , lReturn := .F.

 IF  oCant:nLastKey = 13

  cBarCode := "
"
  cRet := SCAN_OPEN()
  IF valtype( cRet ) = "
C"
    cRet := strtran( cRet , chr(0),"
" )
    FOR i := 1 TO len( cRet )
      IF substr(cRet,i,1) $"
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-/"
        cBarCode += substr(cRet,i,1)
      ENDIF
    NEXT
  ENDIF

  cBarCode := alltrim(cBarcode)+space(15-len(alltrim(cBarcode)))

  IF ! empty( cBarCode )

 *  cFile := files_dir+"
download\"+alltrim(cBarcode)+strzero(nCant,4,0)+".exi"
    cFile := files_dir+"
download\"+alltrim(cBarcode)+".exi"

    nActual := 0
    cMArca:= "
"
    nPrecio:= 0
    nDes := "
"

    IF file( cFile )
      cTxt := memoread( cFile )
      IF ! empty( cTxt )
        nActual := val(substr( cTxt , 1 , 4 ))
        cMarca:= substr( cTxt , 6 , 20 )
        nPrecio := val( substr( cTxt , 27,7))
        cDes := substr( cTxt , 35 )

        oMarca:VarPut("
Marca :"+cMarca )
        oMarca:refresh()
        oPrecio:VarPut("
Precio :"+transform(nPrecio,"99,999.99"))
        oPrecio:refresh()
        oDes:VarPut("
Descripcion :"+left(cDes,32))
        oDes:refresh()

        * Grabar Log
        cLog += cBarcode+strzero(nCant,4,0)+strzero(nActual,4,0)+dtos(date())+time()+cEncargado + CR
        memowrit( files_dir+"
download\inventa.log" , cLog )

        oInvPC:VarPut( "
Inventario PC:"+transform( nActual ,"99999" ))
        oInvPc:refresh()
        IF nActual = nCant
          oMsg:VarPut( "
!! INVENTARIO CORRECTO, CONTINUE !!")
          oCant:VarPut(1)
        ELSEIF nCant > nActual // Sobrantes
          oMsg:VarPut( "
!! SOBRANTES, CUENTE DE NUEVO !!" )
          oCant:VarPut(-999)
        ELSEIF nCant < nActual // Faltantes
          oMsg:VarPut( "
!! FALTANTES, CUENTE DE NUEVO !!" )
          oCant:VarPut(-999)
        ENDIF
        nContador := nContador + 1
        oContador:VarPut("
Contador:"+transform(nContador,"999"))
        oContador:refresh()
      ELSE
        oMsg:VarPut( "
!! ARTICULO NO EXISTE, INTENTE DE NUEVO !!" )
        oCant:VarPut(1)
      ENDIF
    ELSE
             tone(500,4)
       tone(450,3)

      oMsg:VarPut( "
!! ARTICULO NO EXISTE, INTENTE DE NUEVO !!" )
      oCant:VarPut(1)
    ENDIF
    oMsg:refresh()
    oCant:refresh()

    oBarCode:VarPut(space(15))
    oBarCode:refresh()

  ENDIF
 ELSE
  lReturn  := .T.
 ENDIF
RETURN lReturn

FUNCTION CheckBarCode()
* begin
 LOCAL cFile , cRet , nActual := 0 , lReturn := .F. , nHandle , cTxt

 IF oBarCode:nLastKey = 38
  oBarCode:oJump := oCant
  RETURN .T.
 ENDIF

*  if oBarCode:nLastKey = 13

  cBarCode := alltrim(cBarcode)+space(15-len(alltrim(cBarcode)))
  cFile := files_dir+"
download\"+alltrim(cBarcode)+".exi"

  nActual := 0
  cMArca:= "
"
  nPrecio:= 0
  nDes := "
"

  IF file( cFile )
    cTxt := memoread( cFile )
    IF ! empty( cTxt )
      nActual := val(substr( cTxt , 1 , 4 ))
      cMarca:= substr( cTxt , 6 , 20 )
      nPrecio := val( substr( cTxt , 27,7))
      cDes := substr( cTxt , 35 )

      oMarca:VarPut("
Marca :"+cMarca )
      oMarca:refresh()
      oPrecio:VarPut("
Precio :"+transform(nPrecio,"99,999.99"))
      oPrecio:refresh()
      oDes:VarPut("
Descripcion :"+left(cDes,32))
      oDes:refresh()

      oInvPC:VarPut( "
Inventario PC:"+transform( nActual ,"99999" ))
      oInvPc:refresh()
      * Grabar Log
      cLog += cBarcode+strzero(nCant,4,0)+strzero(nActual,4,0)+dtos(date())+time()+cEncargado + CR
      memowrit( files_dir+"
download\inventa.log" , cLog )



      IF nActual == nCant
        oMsg:VarPut( "
!! INVENTARIO CORRECTO, CONTINUE !!")
        oCant:VarPut(1)
      ELSEIF nCant > nActual // Sobrantes
        oMsg:VarPut( "
!! SOBRANTES, CUENTE DE NUEVO !!" )
        oCant:VarPut(-999)
      ELSEIF nCant < nActual // Faltantes
        oMsg:VarPut( "
!! FALTANTES, CUENTE DE NUEVO !!" )
        oCant:VarPut(-999)
      ENDIF
      nContador := nContador + 1
      oContador:VarPut("
Contador:"+transform(nContador,"999"))
      lReturn := .T.
    ELSE
      oMsg:VarPut( "
!! CODIGO DE BARRAS ESTA VACIO!!" )
      oCant:VarPut(1)
    ENDIF
  ELSE
    oMsg:VarPut( "
!! ARTICULO NO EXISTE, INTENTE DE NUEVO !!" )
    oCant:VarPut(1)
  ENDIF
*  ELSE
*    if empty( cBarcode )
*      oMsg:VarPut( "
!! TECLE SU CODIGO DE BARRAS!!" )
*    endif
*  ENDIF

 oMsg:refresh()
 oCant:refresh()
 oContador:refresh()

 IF lReturn
  oBarCode:oJump := oCant
 ENDIF

RETURN lReturn

FUNCTION GrabaEncargado()
* begin
 LOCAL cFile , cRet , cVar

 IF oEncargado:nLastKey = 13
 IF lUsers
   IF USERS->(DbSeek(cEncargado))
     cVar := cBarcode+strzero(nCant,4,0)+strzero(nExist,4,0)+dtos(date())+time()+cEncargado + CR

     cLog += cVAr
     oCant:VarPut(1)
     oCant:refresh()
     oBarCode:VarPut(space(15))
     oBarCode:refresh()
     oMsg:VarPut( "
SE GRABO DIFERENCIAS :"+alltrim(USERS->user_name))
     oMsg:refresh()
     oInvPC:VarPut( "
Inventario PC:"+transform( 0 ,"99999" ))
     oInvPc:refresh()
     oEncargado:VarPut(space(15))
     oEncargado:refresh()
     oEncargado:oJump := oCant


   ELSE
     msginfo( "
Empleado no exite" )
     RETURN .F.
   ENDIF
 ENDIF
 ENDIF
RETURN .T.


FUNCTION Existencias( cBarCode )
* Begin
 LOCAL cFile :=  files_dir+"
download\"+alltrim(cBarcode)+"*.exi"
 LOCAL aFiles := Directory( cFile )
 LOCAL nCount := Len(aFiles)
 LOCAL nExist := NIL
 LOCAL i
 asort( aFiles ,,, {|aX,aY|dtos(aX[F_DATE ])+aX[F_TIME] < dtos(aY[F_DATE ])+aY[F_TIME]})
 FOR i := 1 TO nCount
   nExist := val( substr( aFiles[i][1] , len( aFiles[i][1])-7 ) )
 NEXT
 IF nExist = NIL
  nExist := -777
 ENDIF
RETURN nExist

* Funciones que no corren en Symbol MC3000
FUNCTION cesetmenu()  ; RETURN NIL
FUNCTION getmenu()    ; RETURN NIL
FUNCTION readbitmap() ; RETURN NIL
FUNCTION palbmpread() ; RETURN NIL

****************************************************************************************************

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <Scancapi.h>
#include <mmsystem.h>
#include <uniqueid.h>
LPWSTR AnsiToWide( LPSTR );
#define BUFFER_SIZE       7095
#define DEFAULT_TIMEOUT   10000

LPSCAN_BUFFER        lpScanBuffer          = NULL;
BOOL                 bUseText              = TRUE;
DWORD                dwScanSize            = 7095;
DWORD                dwScanTimeout         = 0;


HANDLE hScanner                = NULL;
TCHAR  szScannerName[MAX_PATH] = TEXT("
SCN1:");
DWORD  dwResult  ;
CHAR   Buffer    ;
UINT   uMsg      ;
DWORD  dwTimeout ;

HB_FUNC( SCAN_OPEN )
{
 dwResult = SCAN_Open( szScannerName, &hScanner );
 if ( dwResult == E_SCN_SUCCESS )
 {
   dwResult = SCAN_Enable( hScanner );
   if ( dwResult == E_SCN_SUCCESS )
    {
      BOOL state = TRUE;
      dwResult = SCAN_SetSoftTrigger(hScanner, &state);
      if (dwResult == E_SCN_SUCCESS)
       {
        // allocate a new scan buffer
        lpScanBuffer = SCAN_AllocateBuffer(TRUE /* data as chars */, BUFFER_SIZE);
        if (lpScanBuffer)
         {
          dwResult = SCAN_ReadLabelWait(hScanner, lpScanBuffer, DEFAULT_TIMEOUT);
          if (dwResult == E_SCN_SUCCESS)
           {
            hb_retclen( (char *)SCNBUF_GETDATA(lpScanBuffer),28);
           }
         }
         SCAN_DeallocateBuffer(lpScanBuffer);
       }
       state = FALSE;
       SCAN_SetSoftTrigger(hScanner, &state);
    }
   else
    {
      MessageBox( GetActiveWindow(), L"
Error en SCAN_Enable", L"Ok", 0 );
    }
 }
 else
 {
  MessageBox( GetActiveWindow(), L"
Error en SCAN_Open", L"Ok", 0 );
 }

}


HB_FUNC (STILLRUN)
{
HWND hWnd;
BOOL lRet = FALSE;
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
hWnd = FindWindow ( NULL,pW);
if (hWnd)
{
 SetForegroundWindow ((HWND) ((ULONG) hWnd |0x01));
 lRet = TRUE;
}
hb_retl( lRet );

}

HB_FUNC (BATTERYLIFE)
{
 BOOL iRet;
 SYSTEM_POWER_STATUS_EX status;
 iRet = GetSystemPowerStatusEx (&status, TRUE);

 hb_retnl ((INT) status.BatteryLifePercent);
}

HB_FUNC (BATTERYINFO)

{
 BOOL iRet;
 SYSTEM_POWER_STATUS_EX status;
 iRet = GetSystemPowerStatusEx (&status, TRUE);

 hb_reta (9);
 hb_stornl ((INT) status.ACLineStatus, -1, 1);
 hb_stornl ((INT) status.BatteryFlag, -1, 2);
 hb_stornl ((INT) status.BatteryLifePercent, -1, 3);
 hb_stornl ((ULONG) status.BatteryLifeTime, -1, 4);
 hb_stornl ((ULONG) status.BatteryFullLifeTime, -1, 5);
 hb_stornl ((INT) status.BackupBatteryFlag, -1, 6);
 hb_stornl ((INT) status.BackupBatteryLifePercent, -1, 7);
 hb_stornl ((ULONG) status.BackupBatteryLifeTime, -1, 8);
 hb_stornl ((ULONG) status.BackupBatteryFullLifeTime, -1, 9);
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sr. Antonio - ScanCAPI.h

Postby MGA » Tue Oct 13, 2009 10:59 am

Muito obrigado Sr. Antonio
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Sr. Antonio - ScanCAPI.h

Postby MGA » Tue Oct 13, 2009 5:24 pm

Sr. Antonio,

agora me ocorre o erro:

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for Pocket PC - January 2009 Harbour development power │▄
│ (c) FiveTech Software, 1993-2009 for Microsoft Windows Pocket PC │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
bar.c
c:\fwppc\include\scandef.h(28) : fatal error C1083: Cannot open include file: 'StrucInf.h': No such file or directory
LINK : fatal error LNK1181: cannot open input file 'bar.obj'
* Linking errors *
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Sr. Antonio - ScanCAPI.h

Postby MGA » Tue Oct 13, 2009 5:36 pm

ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Sr. Antonio - ScanCAPI.h

Postby cllow208 » Tue May 29, 2012 10:06 am

Hi Antonio,

I can't link the example, it says can't open scnapi32.lib, i had been searching for the lib without success for very long time.. :cry: , do i need some other files .dll ? kindly give a view/download link please.

Thanks & best regards,
CL Low
cllow208
 
Posts: 20
Joined: Fri Apr 27, 2012 7:53 am

Re: Sr. Antonio - ScanCAPI.h

Postby Antonio Linares » Tue May 29, 2012 10:58 am

CL Low,

This is the right way to build the library:

impdef.exe scnapi32.def scnapi32.dll

lib.exe /def:scnapi32.def /machine:arm /out:scnapi32.lib

If you send me scnapi32.dll then we will build the lib for you :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sr. Antonio - ScanCAPI.h

Postby cllow208 » Thu May 31, 2012 10:01 am

Hi Antonio,

You had mentioned the above working code was posted by Osvaldo Ramirez, together with the heading files at: http://www.fivetechsoft.com/files/utili ... anCApi.zip, i am still searching and unable to locate scnapi32.dll on symbol's web site (scanner manufacturer).

I am so desperate to test it, do you know to download it? or how to contact Osvaldo Ramirez please..

Kindly help..

Thanks & best regards,

CL Low
cllow208
 
Posts: 20
Joined: Fri Apr 27, 2012 7:53 am

Re: Sr. Antonio - ScanCAPI.h

Postby Antonio Linares » Wed Jun 06, 2012 12:01 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 7 guests