Information générale
Catégorie:
Codage, syntaxe et commandes
So, here is solution of my problem:
*--------------
*GetDefaultPrinterName()
*--------------
LOCAL lcPrinterName
LOCAL lcVersion
LOCAL lcReturnedString
LOCAL lnResult
LOCAL lnVersion
LOCAL lnSize
LOCAL lnPos
lcPrinterName = ''
lcVersion = OS()
IF '5.0' $ lcVersion
*-- OS is Windows NT/2000/XP
lnVersion = VAL(SUBSTR(lcVersion, AT('5', lcVersion), 4))
IF lnVersion >= 5
*-- OS is Windows 2000 or later
DECLARE INTEGER GetDefaultPrinter IN WinSpool.drv STRING @lpReturnedString,;
INTEGER @lpnSize
lnSize = 4096
lcReturnedString = REPLICATE(CHR(0), lnSize)
lnResult = GetDefaultPrinter(@lcReturnedString, @lnSize)
lnPos = AT(CHR(0), lcReturnedString) - 1
IF lnPos > 0
lcPrinterName = SUBSTR(lcReturnedString, 1, lnPos)
ENDIF
ELSE
*-- OS is Windows NT 4.0 or earlier
DECLARE INTEGER GetProfileString IN kernel32 STRING pAppName,;
STRING lpKeyName,;
STRING lpDefault, STRING @lpReturnedString, INTEGER nSize
lnSize = 4096
lcReturnedString = REPLICATE(CHR(0), lnSize)
lnResult = GetProfileString('windows', 'device',;
'#empty#', @lcReturnedString, lnSize)
lnPos = AT(',', lcReturnedString) - 1
IF lnPos > 0
lcPrinterName = LEFT(lcReturnedString, lnPos)
ENDIF
ENDIF
ENDIF
RETURN lcPrinterName
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement