General information
Category:
Coding, syntax & commands
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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only