Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy file .... to lpt1
Message
De
03/03/2004 10:19:26
 
 
À
02/03/2004 22:26:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00821423
Message ID:
00882709
Vues:
25
Hi Alex,

I just implemented this myself. My code below works fine using a network printer:
IF !printit(hdir+'receipt.txt')
   =OKAY("An error ocurred printing the receipt. Please reprint the receipt.")
ENDIF

PROCEDURE printit
PARAMETERS lcfile

IF TYPE('lcfile')<>"C" .or. EMPTY(lcfile)
	RETURN .F.
ENDIF

PRIVATE llreturn
llreturn = .T.

PRIVATE rcptfile
rcptfile = lcfile
PRIVATE rcptprinter
*--SET('PRINTER',3) is a network printer: \\MYSERVER\hplaserj
rcptprinter = SET('PRINTER',3)

PRIVATE lcsafety
lcsafety = SET('SAFETY')
SET SAFETY OFF

DECLARE INTEGER CopyFile IN KERNEL32.DLL ;
   STRING @SourceFileName, ;
   STRING @DestFileName, ;
   INTEGER bFailIfExists
IF CopyFile(@rcptfile,@rcptprinter,0) # 0
   llreturn = .T.
ELSE
   llreturn = .F.
ENDIF

IF TYPE('lcsafety')="C" .and. INLIST(lcsafety,'OFF','ON')
	SET SAFETY &lcsafety
ENDIF

CLEAR DLLS 'CopyFile'

RETURN llreturn
>>Hi Metin,
>>
>>Try this code:
>>
>>DECLARE INTEGER CopyFile IN kernel32;
>>	STRING lpSrcFile, STRING lpDstFile, INTEGER bFail
>>	
>>= CopyFile(cFilename, 'LPT1:', 0)
>>
>>where cFilename is a text file you want to print.
>>
>>No DOS window -- guaranteed :)
>>
>>Network printer names like \\MYSERVER\EPSON can be used as well as LPT1:
>
>Anatoliy,
>
>I keep coming back to you for these answers... I find that CopyFile(cFilename, 'LPT1:', 0) works, but CopyFile(cFilename, '\\MYSERVER\EPSON', 0) does not. Am I doing something wrong?
>
>Thank you very much,
>
>Alex
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform