Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 1804 when compliling AddPrinterDriver Function

Status
Not open for further replies.

DeFreitasM

IS-IT--Management
Dec 20, 2002
4
US
Can some one tell me why My code is erroring when I try to apply the function????

This is the line that errors:
hPrinter = AddPrinterDriver(Server, 4, apd2)
I belive the issue is with the array APD2

CAn any one help Please

Thanks You
M

Code Below.....


Option Explicit
'******************************************************
' Adding Printer Drivers
'******************************************************
Public Type DRIVER_INFO_4
cVersion As Long
pName As String
PEnvironment As String
pdriverPath As String
pDataFile As String
pConfigFile As String
pHelpFile As String
pDependentFiles As String
pMonitorName As String
pDefaultDataType As String
pszzPreviousNames As String
End Type

Public Declare Function AddPrinterDriver Lib "winspool.drv" Alias "AddPrinterDriverA" (ByVal pName As String, ByVal Level As Long, pDriverInfo As Any) As Long

Sub MainDrv()
MsgBox "Driver Creation: " & APD("\\phantom", "4")

End Sub

Function APD(Server As String, _
Level As Long) As Boolean

Dim apd2 As DRIVER_INFO_4
Dim hPrinter As Long
Dim Junk As Long

apd2.pName = "HP 8550"
apd2.PEnvironment = "Win32 x86"
apd2.cVersion = 3
apd2.pdriverPath = "C:\Support\HP2\HPBF402G.DLL"
apd2.pDataFile = "c:\Support\hp2\HPBF402I.PMD"
apd2.pConfigFile = "c:\support\hp2\HPBF402E.DLL"
apd2.pHelpFile = "c:\support\hp2\HPBF402I.HLP"
apd2.pDependentFiles = "HPBF402E.DLL\0HPBF402F.DLL\0HPBF402G.DLL\0HPBF402H.DLL\0HPBF402I.PMD\0HPBF402I.DLL\0HPBF402I.HLP\0HPBF402J.DLL\0HPBF402K.DLL\0HPBAFD32.DLL\0HPBFTM32.DLL\0hp8550_6.ppd\0\0"
apd2.pMonitorName = "PJL monitor"
apd2.pDefaultDataType = "EMF"

'*********************************************************
' Add the printer
' If success then close the returned handle
'*********************************************************

hPrinter = AddPrinterDriver(Server, 4, apd2)
'^^^^^^^^^^^^^^^^^^^^^^^
Junk = MsgBox(Err.LastDllError, vbMsgBoxRight, "DLL Error Code")
Junk = MsgBox(hPrinter, vbCritical, "hPrinter Value")
If hPrinter <> 0 Then
ClosePrinter (hPrinter)
APD = True
Else
APD = False
End If

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top