PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
AddPrinterDriver-VBForums
Results 1 to 2 of 2

Thread: AddPrinterDriver

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    11

    AddPrinterDriver

    I am trying to Add a printer Driver using AddPrinterDriver, its not working. It keeps telling me it cannot find the file specfied. Any Ideas why it would do that? (i've confimed the files do indeed exist and i'm running as admin) And is there anyway to get more detail error messages? here's the code i'm trying to run
    VB Code:
    1. Imports System.Runtime.InteropServices
    2.     Private Overloads Declare Function AddPrinterDriver Lib "winspool.drv" Alias "AddPrinterDriverA" (ByVal pName As String, ByVal Level As Int32, ByRef pDriverInfo As Byte) As Int32
    3.  
    4.     <StructLayout(LayoutKind.Sequential)> Public Class DRIVER_INFO_4
    5.         Public cVersion As Integer ' DWORD
    6.         Public pName As String
    7.         Public pEnvironment As String
    8.         Public pDriverPath As String
    9.         Public pDataFile As String
    10.         Public pConfigFile As String
    11.         Public pHelpFile As String
    12.         Public pDependentFiles As String
    13.         Public pMonitorName As String
    14.         Public pDefaultDataType As String
    15.         Public pszzPreviousNames As String
    16.     End Class
    17.  
    18.     Function addDriver()
    19.         Dim dv As New DRIVER_INFO_4
    20.         With dv
    21.             .cVersion = 3
    22.             .pName = "Apple LaserWriter 12/640 PS"
    23.             .pEnvironment = ""
    24.             .pDriverPath = "c:\temp\pscript5.dll"
    25.             .pDataFile = "c:\temp\aplwmgs1.ppd"
    26.             .pConfigFile = "c:\temp\ps5ui.dll"
    27.             .pHelpFile = "c:\temp\pscript.hlp"
    28.             .pDependentFiles = "c:\temp\pscript.ntf" & vbNullChar & "c:\temp\pscript.hlp" & vbNullChar & "c:\temp\ps5ui.dll" & vbNullChar & "c:\temp\aplwmgs1.ppd" & vbNullChar & "c:\temp\pscript5.dll"
    29.             .pMonitorName = ""
    30.             .pDefaultDataType = "RAW"
    31.             .pszzPreviousNames = ""
    32.         End With
    33.  
    34.         Dim ByteArray() As Byte
    35.         Dim Ptr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(dv))
    36.         ReDim ByteArray(Marshal.SizeOf(dv) - 1)
    37.         'now copy strcutre to Ptr pointer
    38.         Marshal.StructureToPtr(dv, Ptr, False)
    39.         Marshal.Copy(Ptr, ByteArray, 0, Marshal.SizeOf(dv))
    40.         'now use ByteArray ready for use
    41.         Marshal.FreeHGlobal(Ptr)
    42.  
    43.  
    44.  
    45.         Dim rtn As Int32
    46.         rtn = AddPrinterDriver(String.Empty, 2, ByteArray(0))
    47.         Throw New System.ComponentModel.Win32Exception
    48.     End Function
    49.     Sub main()
    50.         adddriver()
    51.     End Sub
    52. End Module

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    11

    Re: AddPrinterDriver

    bump

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width