Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting Printer Properties Beta Testers Needed
Message
General information
Forum:
Visual FoxPro
Category:
Third party products
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01050441
Message ID:
01052232
Views:
11
>>Exactly, so it is correct. When you pass null for the buffer the return value is the count array value that will be need for the buffer. All you need is multiply it with how many byte per each array buffer (depends on DC_xxx value). Anyway, you can hardcoded the way you did, just make sure not to make it too small :-)
>>
>
>The array buffer is what I'm trying to determine. I know it's 1024 for DC_BINS. I also know it's 16384 for DC_BINNAMES. I know this because someone else told me. But how do I know what it is for anything else, like DC_PAPERNAMES?

First, as I mentioned, all you need is the return value multiply by how many byte it takes for each array. For instance:
#Define DC_BINS    6   && each array is in WORD value (2 bytes)
#Define WORD_Size  2

cPrinterName = GetPrinter()
nCountArray = DeviceCapabilities( cPrinterName, 'LPT1:', DC_BINS, Null, 0 )
If (nCountArray > 0)
   cBuffer = space( nCountArray * WORD_Size )
   nReturn = DeviceCapabilities( cPrinterName, 'LPT1:', DC_BINS, @cBuffer, 0 )
   ? nCountArray, nReturn   && these value should be the same
   ? cBuffer
endif

*********

#Define DC_PAPERNAMES      16   && each array is a string with 64 bytes long
#Define DC_PAPERNAMES_Len  64

nCountArray = DeviceCapabilities( cPrinterName, 'LPT1:', DC_PAPERNAMES, Null, 0 )
If (nCountArray > 0)
   cBuffer = space( nCountArray * DC_PAPERNAMES_Len )
   nReturn = DeviceCapabilities( cPrinterName, 'LPT1:', DC_PAPERNAMES, @cBuffer, 0 )
   ? nCountArray, nReturn   && these value should be the same
   ? cBuffer
endif
The rule applies to all DC_xxx value that needs an array buffer. Hope you can understand what I mean :)
Regards

Update:
Sorry, I updated the code and added a litle more comments
Herman
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform