Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get info from a pointer ?
Message
 
To
01/04/2003 11:19:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00772050
Message ID:
00772439
Views:
12
>>Cetin,
>>
>>I've played with SYS(2600) in 7.0/8.0 with great success. Eliminates the need to ever have to use RtlCopyMem().
>
>Oh this is new to me :) Actually I saw it but never tried to use. Would you give a sample for me. Help sample was obscure. Just 10-15 days ago I badly needed something like it but processing even with RtlMoveMemory turned out to be slow so created a FLL instead. Might be a good candidate for next version :)
>(Thing I was trying to do is to read raw data files. A header definition was given. Each record was 228 bytes long holding a total of 123 signed, unsigned - char, short or int values. With over 200 CDs I needed to find a fast solution.)

Cetin,

Happy to, my friend. I've set the call to bold. I think you'll recognize what some of the personal function are and what they do
FUNCTION PrinterDriverName
  * Returns the Printer Driver File Name
    
  LPARAMETERS tcPrinterName
    
  * API Declarations
  DECLARE INTEGER OpenPrinter IN Winspool.drv;
    STRING @pPrinterName, INTEGER @phPrinter,;
    STRING @pDefault
  DECLARE INTEGER ClosePrinter IN Winspool.drv;
    INTEGER hPrinter
  DECLARE INTEGER GetPrinterDriver IN Winspool.drv;
    INTEGER hPrinter, STRING @pEnvironment,;
    INTEGER dLevel, INTEGER pDriverInfo,;
    INTEGER cbBuf, INTEGER @pcbNeeded
  DECLARE INTEGER HeapCreate IN Win32API;
    INTEGER dwOptions, INTEGER dwInitialSize,;
    INTEGER dwMaxSize
  DECLARE INTEGER HeapAlloc IN Win32API;
    INTEGER hHeap, INTEGER dwFlags, INTEGER dwBytes
  DECLARE lstrcpy IN Win32API;
    STRING @lpstring1, INTEGER lpstring2
  DECLARE INTEGER HeapFree IN Win32API;
    INTEGER hHeap, INTEGER dwFlags, INTEGER lpMem
  DECLARE HeapDestroy IN Win32API;
    INTEGER hHeap
  LOCAL lcresult, lcprinter, lnheaphandle, lnhandle,;
    lnsize, lnheap, lnptr, lcstruct
  lcprinter = tcPrinterName
  lnhandle = 0
  lcresult = ""
  IF OpenPrinter(@lcprinter, @lnhandle, 0) # 0
    * Create space on the heap
    lnheaphandle = HeapCreate(0, 4096, 0)
    IF lnheaphandle # 0
      * Get the required size of the DRIVER_INFO_2 structure
      lnsize = 0
      GetPrinterDriver(lnhandle, 0, 2, 0, 0, @lnsize)
      * Get a pointer to an address
      lnheap = HeapAlloc(lnheaphandle, 0, lnsize)
      * Get the information into the structure
      GetPrinterDriver(lnhandle, 0, 2, lnheap, lnsize, @lnsize)
      * Copy the structure to VFP memory
      * In order to get the pointer to the string
      lcstruct = SYS(2600, lnheap, lnsize)
      lnptr = This.StringToInteger(SUBSTR(lcstruct, 5, 4))
      * Initialize the buffer to receive the Driver
      * to MAX_PATH
      lcresult = SPACE(260)
      = lstrcpy(@lcresult, lnptr)
      * Remove the trailing CHR(0)
      lcresult = LEFT(lcresult, AT(CHR(0), lcresult) - 1)
      * Free the heap
      = HeapFree(lnheaphandle, 0, lnheap)
      * Clean up by destorying the handle
      * to the heap
      = HeapDestroy(lnheaphandle)
    ENDIF
    * Close the printer
    = ClosePrinter(lnhandle)
  ENDIF
  RETURN lcresult
ENDFUNC
Just post back if you have any questions (which I doubt< s >).
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform