Imprimir

Imprimir

Postby pymsoft » Fri Nov 10, 2006 9:57 am

Tengo que imprimir en una impresora que viene integrada en un pocket.
Tengo el SDK del productor con manuales y todo... Tengo la .lib (que supongo bastaría agregarla a mi buildce.bat)
Como hago para llamar a cada funcion para imprimir?
Tengo tambien algunas DLL... supongo que contienen lo mismo que las .lib


Gracias por su atencion.


Int Prt_Open( );
Int Prt_Close( );
INT Prt_PortRelease()
INT Prt_PortOpen()
Int Prt_PrinterInit( )
Int Prt_TestPrint( )
INT Prt_PrintText(char *textOut, int option)
INT Prt_PrintBarcode(char *barData, int height, int width, int
barcodeSystem, int codeHRI);
INT Prt_PrintBitmap(LPCTSTR prtFile);
INT Prt_LineFeed(int number);
INT Prt_LineFeedByLine(int line);
INT Prt_BackFeed(int number);
INT Prt_SetDensity(int density);
INT Prt_SetLineSpacing(int linespace);
INT Prt_CheckStatus(PRT_STATUS *status);
INT Prt_CheckPaper(BOOL *blPaper);
INT Prt_CheckHeadTemper(BOOL *blTemper)
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Fri Nov 10, 2006 10:10 am

Pedro,

Puedes implementar unas funciones en C desde tu PRG:
Code: Select all  Expand view
#pragma BEGINDUMP

#include <hbapi.h>

int Prt_Open( void );

HB_FUNC( PRT_OPEN )
{
   hb_retnl( Prt_Open() );
}

#pragma ENDDUMP

y enlazar con tu librería. O bien, puedes implementar accesos dinámicos a las funciones de la DLL:

DLL FUNCTION Prt_Open() AS LONG FROM "Prt_Open" LIB
"TuDll.dll"

En este caso no necesitas enlazar la librería.
regards, saludos

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

Postby pymsoft » Fri Nov 10, 2006 10:14 am

Gracias Antonio,


haré las pruebas correspondientes.
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby pymsoft » Fri Nov 10, 2006 12:46 pm

Definí asi la funcion:

DLL FUNCTION Prt_TestPr() AS LONG FROM "Prt_TestPrint" LIB "Mobitron.Devices.dll"


Pero me da el siguiente error:

Compiling 'teve.prg' and generating preprocessed output to 'teve.ppo'...
teve.prg(894) Error E0030 Syntax error: "parse error at ' Prt_TestPr() AS LONG
FROM "Prt_TestPrint" LIB "Mobitron.Devices.dll"
'"
1 error


Probé a hacerlo con las .lib pero me da otra serie de errores que no tengo idea de como corregir: (escribo aqui una parte)


Compiling...
Harbour Compiler Alpha build 45.0 (Flex)
Copyright 1999-2005, http://www.harbour-project.org/
Compiling 'teve.prg' and generating preprocessed output to 'teve.ppo'...
Lines 891, Functions/Procedures 19
Generating C source output to 'teve.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.

teve.c
c:\lavwin\teve\mobitron\inc\printer.h(22) : error C2146: syntax error : missing
';' before identifier 'Prt_CheckCover'
c:\lavwin\teve\mobitron\inc\printer.h(22) : error C2501: 'INT' : missing storage
-class or type specifiers
c:\lavwin\teve\mobitron\inc\printer.h(23) : error C2146: syntax error : missing
';' before identifier 'Prt_CheckHeadTemper'





Alguna idea?


Gracias
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Fri Nov 10, 2006 1:29 pm

Pedro,

Tienes que añadir a tu PRG

#include "dll.ch"
regards, saludos

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

Postby pymsoft » Fri Nov 10, 2006 1:36 pm

Je... lo acabo de descubrir recién, justo en este momento.

Gracias por tu tiempo.


Hago otra pregunta, visto que no me funciona.

tengo el SDK con dos carpetas
1) Microsoft Embedded Visual C++ Version
2) Microsoft Visual Studio .Net Version

El tema es que las dll estàn en la segunda, esta bien si uso esas? porque en la primera tengo solo las .lib y con esas no funcionó.

Disculpen la ignorancia, pero es el unico modo de aprender...
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Fri Nov 10, 2006 1:51 pm

Pedro,

Prueba a usarlas. Puede ser que sean autocontenidas ó no (ese es el problema de .NET que precisa de un runtime externo).

Una forma rápida de comprobar si puedes usarlas es:

local hDLL := LoadLibrary( "nombre_dll.dll" )

MsgInfo( hDLL )

FreeLibrary( hDLL )
regards, saludos

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

Postby pymsoft » Fri Nov 10, 2006 1:58 pm

ya hice el ejemplo y me devuelve un numero: -2088611840, eso quiere decir que funciona o que no?

gracias.
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Fri Nov 10, 2006 2:01 pm

Pedro,

Funciona :-) ya que estás obteniendo un handle a la DLL.
regards, saludos

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

Postby pymsoft » Fri Nov 10, 2006 2:01 pm

Perfecto :-) ahora a ver entonces por cual motivo no imprime.


gracias nuevamente.
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Fri Nov 10, 2006 2:05 pm

Pedro,

Prueba a hacerlo de esta forma para mantener el handle de la DLL en uso:

local hDLL := LoadLibrary( "TuDLL.dll" )

... tu código

FreeLibrary( hDLL )

DLL FUNCTION Prt_Open() AS LONG FROM "Prt_Open" LIB hDLL
regards, saludos

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

Postby pymsoft » Fri Nov 10, 2006 2:20 pm

En este caso aparece un Alert con este texto: Error code: 0 loading 0



Luego de modificar todo de nuevo y probar con las .lib, me da este error:


teve.c
printerAPI.lib(PRINTERAPI.dll) : fatal error LNK1112: module machine type 'THUMB
' conflicts with target machine type 'ARM'


entiendo que las .lib estan para WM 5.0 y nosotros compilamos para ce 4.2, se puede arreglar en algun modo?
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Sat Nov 11, 2006 9:26 am

Pedro,

> En este caso aparece un Alert con este texto: Error code: 0 loading 0

Has reemplazado "TuDLL.dll" por el nombre "PRINTERAPI.dll" ?

> printerAPI.lib(PRINTERAPI.dll) : fatal error LNK1112: module machine type 'THUMB
' conflicts with target machine type 'ARM'

Esa librería no es para Pocket PC.

Puedes generar una librería a partir de la DLL, haciendo:

implib.exe PRINTERAPI.lib PRINTERAPI.dll

Y prueba a enlazar con esa PRINTERAPI.lib nueva
regards, saludos

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

Postby pymsoft » Sat Nov 11, 2006 10:26 am

en este ejemplo, reeemplacé TuDLL.dll con Mobitron.Devices.dll
y donde dice ... tu còdigo, puse mis lineas de codigo.

local hDLL := LoadLibrary( "TuDLL.dll" )

... tu código

FreeLibrary( hDLL )





--> con implib

C:\lavwin\teve>\BCC55\bin\implib.exe Mobitron.devices.lib Mobitron.Devices.dll

Borland Implib Version 3.0.22 Copyright (c) 1991, 2000 Inprise Corporation
Warning Mobitron.Devices.dll: no exports


-----------------------------------------

Como te dije antes, con todo lo que me mandò el fabricante tengo dos carpetas:


SDK\Microsoft Embedded Visual C++ Version
y
SDK\Microsoft Visual Studio .Net Version



supongo que tengo que usar la primera.
en esa tengo las .lib que me dan ese error.


-------------------------

Esto es parte de un index que tengo en la primera carpeta

INDEX


This document shows constitution of SDK CD. SDK CD has three folders that contains API’ documents, library files, header files and sample sources.

- Documents : contains API’ document and SDK reference note.
- Sample Codes : contains several sample code to help developing of MDT-9000 series.
- SDK Files : constituted of three folders. Each folder contain header files, lib files and dll files.
n inc : contains header files.
n lib : contains lib files.
n target : contains dll files.

Detail Explanation of Each Folder

Documents folder has two pdf files.

“MDT-9000 Series API Reference.PDF” file is MDP-9000 series SDK API. The API describes each c++ function and that usage.

“MDT-9000 Series SDK Release Note.PDF” file introduce the overview of MDT-9000 SDK, and describes the usage of SDK.


(NOTA: en realidad la carpeta con las dll no està, estan solo inc y lib, yo usè las dll de la carpeta de visual studio .NET)
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby Antonio Linares » Sat Nov 11, 2006 11:37 pm

Pedro,

Si la DLL necesita de .NET y si la lib no es para Pocket PC (procesador ARM), necesitarás contactar con el fabricante para que te proporcione una DLL que no sea para .NET ó una LIB que sea para Pocket PC.
regards, saludos

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

Next

Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 1 guest