Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

addPrinterDriver - DRIVER_INFO_3 Structure and vbNullString

94 views
Skip to first unread message

Monika Huk

unread,
Jul 1, 2009, 6:48:01 AM7/1/09
to

Hi,

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


Jim Mack

unread,
Jul 1, 2009, 9:33:53 AM7/1/09
to

Monika Huk wrote:
> Hi,
>
> I want to add a printerdriver using visual basic and the
> api-Function
> addprinterdriver.
>
> This is the code (excerpt)

... 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"

Monika Huk

unread,
Jul 1, 2009, 11:00:13 AM7/1/09
to

Hi Jim,

thanks,

that worked :-)

--
Monika

Dee Earley

unread,
Jul 1, 2009, 11:23:25 AM7/1/09
to
On 01/07/2009 14:33, Jim Mack wrote:
>> 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.
>
> vbNullString is literally nothing, a null pointer typed as a string.
> What you want is vbNullChar, which is a chr$(0) character.

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

Nobody

unread,
Jul 2, 2009, 12:29:58 PM7/2/09
to

"Monika Huk" <Moni...@discussions.microsoft.com> wrote in message
news:0F6468EC-4478-494F...@microsoft.com...

> .pConfigFile =
> "c:\\WINDOWS\\system32\\spool\\drivers\\w32x86\\unidrvui.dll"

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.


0 new messages