プリンタのドライバディレクトリを取得 <TOP>
GetPrinterDriverDirectory プリンタのドライバディレクトリを取得
WindowsXPの例
Windows2000の例
Windows98の例
'================================================================ '= プリンタのドライバディレクトリを取得
'= (GetPrinterDriverDirectory.bas) '================================================================ ' プリンタのドライバディレクトリを取得 Declare Function Api_GetPrinterDriverDirectory& Lib "winspool.drv" Alias "GetPrinterDriverDirectoryA" (ByVal pName$, ByVal pEnvironment$, ByVal level&, ByVal pDriverDirectory$, ByVal cbBuff&, pcbNeeded&) '================================================================ '= Null[Chr$(0)]を取り除く '================================================================ Declare Function TrimNull (item As String) As String Function TrimNull(item As String) As String Var ePos As Integer ePos = InStr(item, Chr$(0)) If ePos Then TrimNull = Left$(item, ePos - 1) Else TrimNull = item End If End Function '------------------------------ Var Level As Long Var cbBuff As Long Var pcbNeeded As Long Var pName As String Var pEnvironment As String Var pDriverDirectory As String Level = 1 cbBuff = 0 pDriverDirectory = Chr$(0) pName = Chr$(0) pEnvironment = Chr$(0) If Api_GetPrinterDriverDirectory(pName, pEnvironment, Level, pDriverDirectory, cbBuff, pcbNeeded) = 0 Then pDriverDirectory = Space$(pcbNeeded) cbBuff = Len(pDriverDirectory) If Api_GetPrinterDriverDirectory(pName, pEnvironment, Level, pDriverDirectory, cbBuff, pcbNeeded) = 1 Then Print TrimNull(pDriverDirectory) End If End If Stop End