I want to add a printerdriver using visual basic and the api-Function
addprinterdriver.
This is the code (excerpt)
---------------------
Public Declare Function AddPrinterDriver Lib "winspool.drv" Alias
"AddPrinterDriverA" (ByVal pName As String, ByVal Level As Long, pDriverInfo
As Any) As Long
Public Type DRIVER_INFO_3
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
End Type
Dim di As DRIVER_INFO_3
With di
.pName = Drivername
.pMonitorName = ""
.cVersion = 3
.pDependentFiles = "unires.dll" & vbNullString & "stdnames.gpd" &
vbNullString & "miprndrv.ini" & vbNullString & "miprndrv.dll" & vbNullString
& "miprnhlp.dll" & vbNullString & vbNullString
.pConfigFile = "c:\\WINDOWS\\system32\\spool\\drivers\\w32x86\\unidrvui.dll"
.pDriverPath = "c:\\WINDOWS\\system32\\spool\\drivers\\w32x86\\unidrv.dll"
.pHelpFile = "unidrv.hlp"
.pDataFile = "c:\\WINDOWS\\system32\\spool\\drivers\\w32x86\\miprndrv.gpd"
.pEnvironment = WinNTEnvironment
If AddPrinterDriver("", .cVersion, di) = 0 Then
WriteToLog "InstallDriver: " & RaiseAPIError, LogFile
miInstallDriver = False
Exit Function
Else
WriteToLog "InstallDriver: success", LogFile
miInstallDriver = True
End If
End With
---------------------
The installation always returns with this error:
InstallDriver: 2: Das System kann die angegebene Datei nicht finden.
Using the sysinternal tool "filemon" I realized, that obviously all the
filenames given in di.pDependentFiles are concatenated and used as a filename
to look for - the vbNullString-Separator is not recognized.
Line of the filemon-log:
12270 12:17:02 spoolsv.exe:476 OPEN C:\WINDOWS\System32\spool\DRIVERS\W32X86\unires.dllstdnames.gpdmiprndrv.inimiprndrv.dllmiprnhlp.dll NOT
FOUND Options: Open Sequential Access: Read
Any help with this problem is appreciated,
thanks
Monika
... snipped ...
> Using the sysinternal tool "filemon" I realized, that obviously all
> the
> filenames given in di.pDependentFiles are concatenated and used as
> a filename
> to look for - the vbNullString-Separator is not recognized.
>
> Line of the filemon-log:
> 12270 12:17:02 spoolsv.exe:476 OPEN
>
C:\WINDOWS\System32\spool\DRIVERS\W32X86\unires.dllstdnames.gpdmiprndr
v.inimiprndrv.dllmiprnhlp.dll
> NOT
> FOUND Options: Open Sequential Access: Read
vbNullString is literally nothing, a null pointer typed as a string.
What you want is vbNullChar, which is a chr$(0) character.
--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"
thanks,
that worked :-)
--
Monika
You may want to check out this page that explains Null and its variations:
http://hashvb.earlsoft.co.uk/Null
--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
iCode Systems
You need to remove all extra "\". It's an escape character in C++, so it has
to be doubled when a path is hard coded into the source file(in C++), but
not in VB.