Article View: fj.lang.visualbasic
Article #1223Re: プリンターの詳細情報の取得
From: Sato Masahiro
Date: Mon, 20 Oct 1997 00:00
Date: Mon, 20 Oct 1997 00:00
72 lines
2556 bytes
2556 bytes
In article <01bcdd0d$d50acf20$29c2ebca@xc13>, yyamas@osk3.3web.ne.jp says...
>Win32$B$N(BGetPrinter$B4X?t$G=PMh$k$HJ9$$$?$N$G$9$,!">e<j$/$$$-$^$;$s!#(B
$B$^$:!"9=B$BN$N(B PRINTER_INFO_2 $B$r!"%a%s%PJQ?t$rA4$F(B Long $B7?$H$7$F(B
$B@k8@$7$^$9!#0J2<$O!"(BGetPrinter $B4X?t$N%5%s%W%k%3!<%I$G$9!#(B
$BNc(B1: $B%W%j%s%?>pJs$N<hF@(B
OpenPrinter "PrinterName", hPrinter, 0
' $BI,MW$J%P%$%H?t$r<hF@(B
ReDim Bytes(0)
GetPrinter hPrinter, 2, Bytes(0), 0, Needed
' $B>pJs$N<hF@(B
ReDim Bytes(Needed - 1)
GetPrinter hPrinter, 2, Bytes(0), Needed, Needed
'$B>pJs$r9=B$BN$K3JG<(B
ReadProcessMemory hProcess, Bytes(0), PrinterInfo2, _
Len(PrinterInfo2), ReadCount
'$B>pJs$NI=<((B
MsgBox "PrinterName: " & GetStrByAddress(PrinterInfo2.pServerName)
MsgBox "Status: " & PrinterInfo2.Status
MsgBox "PortName: " & GetStrByAddress(PrinterInfo2.pPortName)
ClosePrinter hPrinter
$B>e5-%5%s%W%kCf$G!"(BGetStrByAddress $B$H$$$&4X?t$O!"0J2<$N$h$&$K(B
$BDj5A$7$^$9!#(B
$BNc(B2: $B%"%I%l%9CM$+$iJ8;zNsCM$r:n@.(B
Declare Function ReadProcessMemoryByAdr Lib "kernel32" _
Alias "ReadProcessMemory" ( _
ByVal hProcess As Long, _
ByVal lpBaseAddress As Long, _
lpBuffer As Any, _
ByVal nSize As Long, _
lpNumberOfBytesWritten As Long) As Long
Public Function GetStrByAddress(p As Long) As String
Dim S As String
Dim I As Long
Dim ReadCount As Long
Dim ReadByte As Byte
Dim hProcess As Long
hProcess = GetCurrentProcess()
S = ""
I = p
ReadProcessMemoryByAdr hProcess, I, ReadByte, 1, ReadCount
While ReadByte <> 0
S = S + ChrB(ReadByte)
I = I + 1
ReadProcessMemoryByAdr hProcess, I, ReadByte, 1, ReadCount
Wend
S = StrConv(S, vbUnicode)
GetStrByAddress = S
End Function
hProcess $B$NCM$O!"(BGetCurrentProcess $B4X?t$K$h$C$F<hF@$7$^$9!#(B
$B4*0c$$$J$I$"$j$^$7$?$i!"$I$J$?$+$4;XE&$r$*4j$$$$$?$7$^$9!#(B
--
$B:4F#@59((B <masahiro@cij.co.jp>
Technical Details
Message-ID:
<62fgbt$a54@cij-gw.ykhm.cij.co.jp>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01bcdd0d$d50acf20$29c2ebca@xc13>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: 105c2e,7d1503bfe340fdac X-Google-Attributes: gid105c2e,public From: masahiro@cij.co.jp (Sato Masahiro) Subject: Re: プリンターの詳細情報の取得 Date: 1997/10/20 Message-ID: <62fgbt$a54@cij-gw.ykhm.cij.co.jp> X-Deja-AN: 282029956 References: <01bcdd0d$d50acf20$29c2ebca@xc13> Organization: Computer Institute of Japan, Ltd. Newsgroups: fj.lang.visualbasic