Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / July 2009



Tip: Looking for answers? Try searching our database.

addPrinterDriver - DRIVER_INFO_3 Structure and vbNullString

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Monika Huk - 01 Jul 2009 11:48 GMT
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 - 01 Jul 2009 14:33 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> This is the code (excerpt)

   ... snipped ...

> Using the sysinternal tool "filemon" I realized, that obviously all
> the
[quoted text clipped - 4 lines]
> 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.

Signature

  Jim Mack
  Twisted tees at http://www.cafepress.com/2050inc
  "We sew confusion"

Monika Huk - 01 Jul 2009 16:00 GMT
Hi Jim,

thanks,

that worked :-)

Signature

Monika

> > Hi,
> >
[quoted text clipped - 22 lines]
> vbNullString is literally nothing, a null pointer typed as a string.
> What you want is vbNullChar, which is a chr$(0) character.
Dee Earley - 01 Jul 2009 16:23 GMT
>> Using the sysinternal tool "filemon" I realized, that obviously
>> all the filenames given in di.pDependentFiles are concatenated and
[quoted text clipped - 3 lines]
> 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

Signature

Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team

iCode Systems

Nobody - 02 Jul 2009 17:29 GMT
> .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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.