tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル Re^2: AddPrinterDriverがうまくいきません
投稿日: 2010/10/20(Wed) 23:00
・AddPrinterDriverのAPI宣言に Alias "AddPrinterDriverW" を付け加えました
・DRIVER_INFO_3のpDependentFilesプロパティの最後に & vbNullChar & vbNullChar を付けました


Private Declare Unicode Function AddPrinterDriver Lib "winspool.drv" Alias "AddPrinterDriverW" _
           (ByVal pName As String, _
            ByVal Level As Integer, _
            ByRef pDriverInfo As DRIVER_INFO_3) As <MarshalAs(UnmanagedType.Bool)> Boolean

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode, Pack:=4)> _
Private Structure DRIVER_INFO_3
    Public cVersion As Int32
    Public pName As String
    Public pEnvironment As String
    Public pDriverPath As String
    Public pDataFile As String
    Public pConfigFile As String
    Public pHelpFile As String
    Public pDependentFiles As String
    Public pMonitorName As String
    Public pDefaultDataType As String
End Structure

Public Shared Function DriverInstall(ByVal strDriverName As String) As Boolean
    Dim di As DRIVER_INFO_3
    With di
    .cVersion = 3
    .pConfigFile = "ps5ui.dll"
    .pDataFile = strDriverName & ".ppd"
    .pDependentFiles = "pscript.ntf" & vbNullChar _
            & "pscript.hlp" & vbNullChar _
            & "ps5ui.dll" & vbNullChar _
            & strDriverName & ".ppd" & vbNullChar _
            & "pscript5.dll" & vbNullChar & vbNullChar
    .pDriverPath = "pscript5.dll"
    .pEnvironment = "Windows NT x86"
    .pHelpFile = "pscript5.hlp"
    .pMonitorName = String.Empty
    .pName = strDriverName
    .pDefaultDataType = "RAW"
    End With

    If Not AddPrinterDriver(Nothing, 3, di) Then
        Dim ExcptWin32 As New Win32Exception(Marshal.GetLastWin32Error())
        MessageBox.Show(ExcptWin32.Message, "Win32Err", MessageBoxButtons.OK)
        Return False
    End If
    Return True
End Function

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)