Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Default printer name
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00616962
Message ID:
00618012
Vues:
19
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
Fil
Voir

Click here to load this message in the networking platform