Página 1 de 1

Usando DLL da Bematech no Harbour 3.x

Enviado: 21 Set 2011 08:22
por Itamar M. Lins Jr.
Ola!
Eu faço dessa forma:

Código: Selecionar todos

#include "dll.ch"

   If File("bemafi32.dll")
      hDll:=DllLoad("bemafi32.dll")
   Else
      MsgStop("Falha carregando bemafi32.dll")
      return .f.
   EndIf

 nRetVal := DllCall(hDll,DLL_OSAPI,"Bematech_FI_LeituraX")
//ou passsando parametros.
nRetVal := DllCall(hDll,DLL_OSAPI,"Bematech_FI_LeituraMemoriaFiscalData",ini,fim)
hDll:=DllUnLoad("bemafi32.dll")
Lembrando que hDll é do tipo "P"

Saudações,
Itamar M. Lins Jr.

Usando DLL da Bematech no Harbour 3.x

Enviado: 21 Set 2011 08:36
por lucimauro
Obrigado itamar por sua ajuda.

no exemplo acima que voce me mandou,que esta bem claro tenho duas duvidas.

1. Quando eu mando compilar da erro porque o harbour 3.00 nao encontrar a funcao DLLCALL, ele diz que nao existe?

2. Essa variavel DLL_OSAPI, seria 32(bits) ou 60(bits) é isso?



Desde ja agradeço sua ajuda.

Usando DLL da Bematech no Harbour 3.x

Enviado: 21 Set 2011 08:50
por Itamar M. Lins Jr.
Ligou a lib HBXPP ? essa é a lib de compatilidade com o xBase++
Praticamente todos os comandos do xBase++ estão nela.

Código: Selecionar todos

/*
 * $Id: dll.ch 14688 2010-06-04 13:32:23Z vszakats $
 */

/*
 * Harbour Project source code:
 * Xbase++ compatibility header
 *
 * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
 * www - http://harbour-project.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
 *
 * As a special exception, the Harbour Project gives permission for
 * additional uses of the text contained in its release of Harbour.
 *
 * The exception is that, if you link the Harbour libraries with other
 * files to produce an executable, this does not by itself cause the
 * resulting executable to be covered by the GNU General Public License.
 * Your use of that executable is in no way restricted on account of
 * linking the Harbour library code into it.
 *
 * This exception does not however invalidate any other reasons why
 * the executable file might be covered by the GNU General Public License.
 *
 * This exception applies only to the code released by the Harbour
 * Project under the name Harbour.  If you copy code from other
 * Harbour Project or Free Software Foundation releases into a copy of
 * Harbour, as the General Public License permits, the exception does
 * not apply to the code that you add in this way.  To avoid misleading
 * anyone as to the status of such modified files, you must delete
 * this exception notice from them.
 *
 * If you write modifications of your own for Harbour, it is your choice
 * whether to permit this exception to apply to your modifications.
 * If you do not wish that, delete this exception notice.
 *
 */

/* NOTE: This file is also used by C code. */

#ifndef _DLL_CH
#define _DLL_CH

#define DLL_CDECL                   0x08
#define DLL_STDCALL                 0x20
#define DLL_SYSTEM                  0x04
#if defined( __PLATFORM__WINDOWS )
#define DLL_OSAPI                   DLL_STDCALL
#elif defined( __PLATFORM__OS2 )
#define DLL_OSAPI                   DLL_SYSTEM
#else
#define DLL_OSAPI                   DLL_CDECL
#endif

/* Only for compatiblity.
   Harbour always copies the string to a temporary buffer. */
#define DLL_CALLMODE_COPY           0
#define DLL_CALLMODE_NORMAL         DLL_CALLMODE_COPY

#endif /* _DLL_CH */

Código: Selecionar todos

/*
 * $Id: testdll.prg 14688 2010-06-04 13:32:23Z vszakats $
 */

/*
 * Harbour Project source code:
 *    DLL call demonstration.
 *
 * Copyright 2008 Viktor Szakats (harbour.01 syenar.hu)
 * www - http://harbour-project.org
 *
 */

#include "simpleio.ch"

#include "dll.ch"

#define MAX_PATH 260

PROCEDURE Main()
   LOCAL hDLL
   LOCAL cData

   #if defined( __PLATFORM__WINDOWS )

   IF hb_FileExists( "pscript.dll" )
      hDLL := DllLoad( "pscript.dll" )
      cData := Space( 24 )
      DllCall( hDll, DLL_OSAPI, "PSGetVersion", @cData )
      ? ">" + cData + "<"
      DllUnload( hDLL )

      // ; Testing failure 1
      hDLL := DllLoad( "pscript.dll" )
      cData := Space( 24 )
      DllCall( hDll, DLL_OSAPI, "PSGet__Version", @cData )
      ? ">" + cData + "<"
      DllUnload( hDLL )
   ENDIF

   // ; Testing failure 2
   hDLL := DllLoad( "nothere.dll" )
   cData := Space( 24 )
   DllCall( hDll, NIL, "PSGetVersion", @cData )
   ? cData
   DllUnload( hDLL )

   #define MB_OK                       0x00000000
   #define MB_OKCANCEL                 0x00000001
   #define MB_ABORTRETRYIGNORE         0x00000002
   #define MB_YESNOCANCEL              0x00000003
   #define MB_YESNO                    0x00000004
   #define MB_RETRYCANCEL              0x00000005
   #define MB_CANCELTRYCONTINUE        0x00000006
   #define MB_ICONHAND                 0x00000010
   #define MB_ICONQUESTION             0x00000020
   #define MB_ICONEXCLAMATION          0x00000030
   #define MB_ICONASTERISK             0x00000040
   #define MB_USERICON                 0x00000080
   #define MB_DEFBUTTON2               0x00000100
   #define MB_DEFBUTTON3               0x00000200
   #define MB_DEFBUTTON4               0x00000300
   #define MB_SYSTEMMODAL              0x00001000
   #define MB_TASKMODAL                0x00002000
   #define MB_HELP                     0x00004000
   #define MB_NOFOCUS                  0x00008000
   #define MB_SETFOREGROUND            0x00010000
   #define MB_DEFAULT_DESKTOP_ONLY     0x00020000
   #define MB_TOPMOST                  0x00040000
   #define MB_RIGHT                    0x00080000
   #define MB_RTLREADING               0x00100000

   ? "MsgBox:", DllCall( "user32.dll", DLL_OSAPI, "MessageBoxA", 0, "Hello world!", "Harbour sez", hb_bitOr( MB_OKCANCEL, MB_ICONEXCLAMATION, MB_HELP ) )

   /* Force Windows not to show dragged windows contents */

   #define SPI_SETDRAGFULLWINDOWS 37

   ? "Full content drag: OFF"
   ? DllCall( "user32.dll", DLL_OSAPI, "SystemParametersInfoA", SPI_SETDRAGFULLWINDOWS, 0, 0, 0 )
   Inkey( 0 )

   ? "Full content drag: ON"
   ? DllCall( "user32.dll", DLL_OSAPI, "SystemParametersInfoA", SPI_SETDRAGFULLWINDOWS, 1, 0, 0 )
   Inkey( 0 )

   #define CSIDL_APPDATA               0x001a /* <username>\Application Data */
   #define CSIDL_ADMINTOOLS            0x0030 /* <username>\Start Menu\Programs\Administrative Tools */

   ? "DLLCALL"
   cData := Space( MAX_PATH )
   ? DllCall( "shell32.dll", DLL_OSAPI, "SHGetFolderPathA", 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
   ? "REF:", cData

   ? "DLLCALL"
   cData := Space( MAX_PATH )
   ? DllCall( "shell32.dll", DLL_OSAPI, "SHGetFolderPathW", 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
   ? "REF:", cData

   #endif

   RETURN
Saudações,
Itamar M. Lins Jr.