Information générale
Catégorie:
Fonctions Windows API
> You can allocate the structure itself in a VFP string, but the pointers to > strings need to be allocated in memory outside the VFP memory space. My
> CLSHEAP class could handle the allocations, as could Paul Tatavu's POINTERS class. Using CLSHEAP:
[snip...]
> When you've finished, invoke oHeap.Dealloc against whatever you've finished with; releasing oHeap (ie oheap = NULL) will release all remain allocs
> and release the heap owned by the object.
Ed,
Thanks for the sample code. I downloaded your CLSHEAP.PRG file and successfully incorporated your sample into my call to AddPrinterDriver. It seems, however, that every time I call AddPrinterDriver it returns true no matter what I specify for the print driver. Here's the code that I'm using:
---
FUNCTION InstallGenericDriver
LOCAL lcMyNameString,lcMyEnvString,lcPath,lcFilename,lcConfigFilename
#DEFINE SizeOfName 2
#DEFINE SizeOfEnvironment 2
#DEFINE SizeOfDriverPath 2
#DEFINE SizeOfFilename 2
#DEFINE SizeOfConfigFilename 2
DECLARE INTEGER AddPrinterDriver IN WINSPOOL.DRV ;
STRING @ lpName, ;
INTEGER Level, ;
STRING @ lpDriverInfo
SET PROCEDURE TO CLSHEAP.PRG ADDITIVE
lnVersion = 4.00
lcMyNameString = "Generic"
lcMyEnvString = ""
lcPath = "TTY.DRV"
lcFilename = "TTY.DRV"
lcConfigFileName = ""
oHeap = CREATEOBJ('Heap')
lnNameBuffer = oHeap.Alloc(SizeOfName)
oHeap.CopyTo(lnNameBuffer,lcMyNameString+CHR(0))
lnEnvBuffer = oHeap.Alloc(SizeOfEnvironment)
oHeap.CopyTo(lnEnvBuffer,lcMyEnvString + CHR(0))
lnDriverPath = oHeap.Alloc(SizeOfDriverPath)
oHeap.CopyTo(lnDriverPath,lcPath + CHR(0))
lnFileBuff = oHeap.Alloc(SizeOfFilename)
oHeap.CopyTo(lnFileBuff,lcFilename + CHR(0))
lnConfig = oHeap.Alloc(SizeOfConfigFilename)
oHeap.CopyTo(lnConfig,lcConfigFilename + CHR(0))
lcDriverInfo2 = NumTODWORD(lnVersion) + ;
NumToDWORD(lnNameBuffer) + ;
NumToDWORD(lnEnvBuffer) + ;
NumToDWORD(lnDriverPath) + ;
NumTODWORD(lnFileBuff) + ;
NumToDWORD(lnConfig)
lnRetVal = AddPrinterDriver("", 2, @lcDriverInfo2)
messagebox("AddPrinterDriver returned " + iif(lnRetVal <> 0, "TRUE", "FALSE"), 48, "")
RETURN lnRetVal
oHeap.Dealloc()
ENDFUNC
---
I have a sinking suspicion that my problem is coming from the definitions made inside of lcDriverInfo2. For those who have tried installing printer drivers before, are those the correct filenames?
Also, another quick question. If the driver is successfully installed, will it present itself inside of WIN.INI in the Devices and PrinterPorts sections?
Thanks in advance.
Précédent
Suivant
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