WDM プリンタINFファイル解析一般 新しいページはコチラ

提供: yonewiki
移動: 案内, 検索
(Copy Sections)
 
1行: 1行:
 +
[[Windows Driver Model]]に戻る
 
== '''概要''' ==
 
== '''概要''' ==
 
 WDM プリンタインストールの解析記事です。最近はPrinterってPDFに出力するだけだったりすることも多いですが、そういったプリンタのインストールってどんな感じの動きをするのかを知るのがこの記事になります。管理人程度の知識ではさほど解析できないと思いますが、まずはやってみましょう。
 
 WDM プリンタインストールの解析記事です。最近はPrinterってPDFに出力するだけだったりすることも多いですが、そういったプリンタのインストールってどんな感じの動きをするのかを知るのがこの記事になります。管理人程度の知識ではさほど解析できないと思いますが、まずはやってみましょう。
618行: 619行:
  
 
==== ''' [DestinationDirs] '''====
 
==== ''' [DestinationDirs] '''====
 ファイルのコピー先を指定する部分です。DefaultDestDir=66000は既定の配布先を指定するもので66000はプリンタドライバの配置をする既定のディレクトリ名を示します。番号が特定のディレクトリ名を保持していて、この番号によるディレクトリ名指定の管理はかなりの数が登録されています。66000はGetPrinterDriverDirectoryというAPIを実行して返却される値です。Windows10のamd64アーキテクチャーの場合はC:\Windows\System32\spool\drivers\x64が返ってきます。
+
 ファイルのコピー先を指定する部分です。DefaultDestDir=66000は既定の配布先を指定するもので66000はプリンタドライバの配置をする既定のディレクトリ名を示します。番号が特定のディレクトリ名を保持していて、この番号によるディレクトリ名指定の管理はかなりの数が登録されています。66000はGetPrinterDriverDirectoryというAPIを実行して返却される値です。diridと呼ばれています。Windows10のamd64アーキテクチャーの場合はC:\Windows\System32\spool\drivers\x64が返ってきます。[https://docs.microsoft.com/ja-jp/windows-hardware/drivers/install/using-dirids dirid]についてはリンク先に記述があります。
  
  
<syntaxhighlight2 lang="VBA">
+
 エクセルがあれば、以下のコードを[[VBA]]のエディタに張り付けてGetPrnterDriverDirectoryの内容を確かめることができます。
 +
<syntaxhighlight2 lang="VB">
 
Declare PtrSafe Function BeepAPI Lib "kernel32.dll" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
 
Declare PtrSafe Function BeepAPI Lib "kernel32.dll" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
 
Declare PtrSafe Function GetPrinterDriverDirectory Lib "winspool.drv" Alias "GetPrinterDriverDirectoryA" _
 
Declare PtrSafe Function GetPrinterDriverDirectory Lib "winspool.drv" Alias "GetPrinterDriverDirectoryA" _
639行: 641行:
 
   Dim pDriverDirectory As String
 
   Dim pDriverDirectory As String
 
    
 
    
  'initialization to determine size of buffer required
 
 
   level = 1    'must be 1
 
   level = 1    'must be 1
 
   cbBuff = 0  'must be 0 initially
 
   cbBuff = 0  'must be 0 initially
 
   pDriverDirectory = vbNullString  'must be null string initially
 
   pDriverDirectory = vbNullString  'must be null string initially
 
    
 
    
  'string that specifies the name of the
 
  'server on which the printer driver resides.
 
  'If this parameter is vbNullString the
 
  'local driver-directory path is retrieved.
 
 
   pName = vbNullString
 
   pName = vbNullString
 
    
 
    
  'string that specifies the environment
 
  '(for example, "Windows NT x86", "Windows NT R4000",
 
  '"Windows NT Alpha_AXP", or "Windows 4.0"). If
 
  'this parameter is NULL, the current environment
 
  'of the calling application and client machine
 
  '(not of the destination application and print
 
  'server) is used.
 
 
   pEnvironment = vbNullString
 
   pEnvironment = vbNullString
 
    
 
    
  'find out how large the buffer
 
  'needs to be (pcbNeeded). Call will return 0.
 
 
   If GetPrinterDriverDirectory(pName, _
 
   If GetPrinterDriverDirectory(pName, _
 
                                 pEnvironment, _
 
                                 pEnvironment, _
667行: 655行:
 
                                 cbBuff, _
 
                                 cbBuff, _
 
                                 pcbNeeded) = 0 Then
 
                                 pcbNeeded) = 0 Then
   
+
      '1回目の呼び出しでは返却で必要な文字数を返すために呼び出します。
   
+
      '最初はディレクトリ値は得られません。
    'create a buffer large enough for the
+
 
    'string and a trailing null
+
 
       pDriverDirectory = Space$(pcbNeeded)
 
       pDriverDirectory = Space$(pcbNeeded)
 
       cbBuff = Len(pDriverDirectory)
 
       cbBuff = Len(pDriverDirectory)
 
          
 
          
    'call again. Success = 1
 
 
       If GetPrinterDriverDirectory(pName, _
 
       If GetPrinterDriverDirectory(pName, _
 
                                   pEnvironment, _
 
                                   pEnvironment, _
681行: 667行:
 
                                   cbBuff, _
 
                                   cbBuff, _
 
                                   pcbNeeded) = 1 Then
 
                                   pcbNeeded) = 1 Then
 +
        '2回目の呼び出しでは返却で必要な文字数設定して呼び出しているので
 +
        'ディレクトリ値が得られます。
 
                                          
 
                                          
          'result
+
        Debug.Print Left$(pDriverDirectory, pcbNeeded)
            Text1 = Left$(pDriverDirectory, pcbNeeded)
+
        '取得できた値がイミディエイトウィンドウに表示されます。
           
+
       End If  
       End If 'GetPrinterDriverDirectory/2
+
   End If  
   End If 'GetPrinterDriverDirectory/1
+
 
+
 
End Sub
 
End Sub
  
693行: 679行:
  
 
</syntaxhighlight2>
 
</syntaxhighlight2>
 +
 +
 
 +
 +
==== ''' [SourceDisksFiles] '''====
 +
 [SourceDisksFiles]は[SourceDisksFiles.amd64]のようにアーキテクチャー情報が付加されたものを対象にすることができます。この欄で先述したCopyFileセクションで記載したファイル一つ一つの詳細情報を記述する部分です。ファイルがどこにあるのかといた情報をつけ足します。たとえINFファイルと同じ位置にあったとしても、ディレクトリの位置がどこなのかを明示する必要があります。
 +
 +
 +
*<span style = "background:linear-gradient(transparent 75%, #ff7f7f 75%); font-weight:bold; ">78行目:DNuanuni.dll    = [1]1<span>(</span>=diskid<span>)</span>,[2]<span>(</span>=subdir<span>)</span>,[3]<span>(</span>upgradecode<span>)</span>,[4]<span>(</span>newinstallcode<span>)</span>,[5]<span>(</span>spare<span>)</span>,[6]<span>(</span>spare<span>)</span>,[7]<span>(</span>newfilename<span>)</span>,11<span>(</span>=diskid<span>)</span>,\amd64<span>(</span>=subidir<span>)</span></span>
 +
: これを紐解くのは難しい。なんで1の後ろにカンマ7つもあるん?コレって感じです。1と11を先述したdiridで1はINFファイルがあるInstalFileドライブを意味しています。11はC:¥Windows¥System32です。WindowsディレクトリはほとんどのPCで共通ですが、名前を変更することもできるので、11が同じ役割のフォルダという風に紐づけられています。diridはややこしいけど、プリンタドライバをインストールする技術としては必要不可欠な便利なシステムです。
 +
 +
 +
: カンマ7つは別の意味をもっています。[1]diskid, [2]subdir, [3]upgradecode, [4]newinstallcode, [5]spare, [6]spare, [7]newfilename
 +
 +
 
  
 
=== ''' NTPRINT.INI '''===
 
=== ''' NTPRINT.INI '''===
974行: 974行:
  
 
</syntaxhighlight2>
 
</syntaxhighlight2>
 +
 +
 
 +
 +
[[Windows Driver Model]]に戻る

2021年5月12日 (水) 00:00時点における最新版



個人用ツール
名前空間

変種
操作
案内
ツールボックス