田舎エンジニアのBlog

~自宅も会社も田んぼに囲まれてますが何か?~

目次

Blog 利用状況

ニュース

自己紹介

リンク

スポンサー

書庫

日記カテゴリ

[VB.NET]プリンタの用紙サイズの番号の取得(2)

[VB.NET]プリンタの用紙サイズの番号の取得

 

前回のコメントでUnicode版という宿題をいただいたので作ってみました。

なかなか倒せませんでしたが(^^;

 

DeviceCapabilitiesW関数でpOutputへの値をUnicodeで取得するために、DllImportAttribute属性を使うようにしました。

基本は前回と同じ動作となってます。

 

Imports System
Imports System.Text
Imports System.Runtime.InteropServices

Module Module1
    <DllImport("WINSPOOL.DRV", CharSet:=CharSet.Unicode, EntryPoint:="DeviceCapabilitiesW")> _
    Private Function DeviceCapabilitiesNames(ByVal pDevice As String, _
                                        ByVal pPort As String, _
                                        ByVal fwCapability As Integer, _
                                        ByVal pOutput As String, _
                                        ByVal pDevMode As IntPtr) As Integer
    End Function
    <DllImport("WINSPOOL.DRV", CharSet:=CharSet.Unicode, EntryPoint:="DeviceCapabilitiesW")> _
    Private Function DeviceCapabilitiesPapers(ByVal pDevice As String, _
                                        ByVal pPort As String, _
                                        ByVal fwCapability As Integer, _
                                        ByVal pOutput As Short(), _
                                        ByVal pDevMode As IntPtr) As Integer
    End Function
    Private Const DC_PAPERS As Integer = 2
    Private Const DC_PAPERNAMES As Integer = 16

    Sub Main()
        Dim PrinterName As String = "EPSON PM-G720 (M)"
        Dim PortName As String = "USB001"
        Dim paperName As String = "A3"
        Dim no As Short = GetPaperNumber(PrinterName, PortName, paperName)
        Console.WriteLine("プリンタ {0} の用紙 {1} の番号は {2} です。", PrinterName, paperName, no)
        Console.ReadKey()
    End Sub

    Private Function GetPaperNumber(ByVal PrinterName As String, ByVal PortName As String, ByVal PaperName As String) As Short
        Dim PaperNamesCount As Integer
        '用紙名のリストの数を取得
         PaperNamesCount = DeviceCapabilitiesNames(PrinterName, PortName, DC_PAPERNAMES, CType(Nothing, String), IntPtr.Zero)
        Dim PaperNames As String = New String(" "c, PaperNamesCount * 64)
        Call DeviceCapabilitiesNames(PrinterName, PortName, DC_PAPERNAMES, PaperNames, IntPtr.Zero)
        Dim paperIndex As Integer = 0
        For i As Integer = 0 To PaperNamesCount - 1
            Dim paper As String = PaperNames.Substring(i * 64, 64)
            paper = paper.Substring(0, paper.IndexOf(Nothing))
            If paper.Trim().CompareTo(PaperName) = 0 Then
                paperIndex = i
                Exit For
            End If
        Next

        Dim paperNumberCount As Integer
        '用紙サイズ番号のリストの数を取得
        paperNumberCount = DeviceCapabilitiesPapers(PrinterName, PortName, DC_PAPERS, CType(Nothing, Short()), IntPtr.Zero)
        Dim paperNumbers As Short()
        ReDim paperNumbers(paperNumberCount - 1)
        Call DeviceCapabilitiesPapers(PrinterName, PortName, DC_PAPERS, paperNumbers, IntPtr.Zero)

        Return paperNumbers(paperIndex)
    End Function
End Module

 

投稿日時 : 2008年12月17日 0:21

コメントを追加

# re: [VB.NET]プリンタの用紙サイズの番号の取得(2) 2008/12/17 13:48 通りすがり

DllImportの閉じ括弧が何故かありませんよ!

# re: [VB.NET]プリンタの用紙サイズの番号の取得(2) 2008/12/17 23:06 nakaP

>通りすがりさん
しゅ、修正しました!!

# rjvsdfFCkCjpFFEczQO 2021/07/03 4:34 https://www.blogger.com/profile/060647091882378654

This is one awesome blog.Really looking forward to read more. Great.

# vibramycin 100 mg https://doxycyline1st.com/
odering doxycycline 2022/02/26 0:45 Jusidkid

vibramycin 100 mg https://doxycyline1st.com/
odering doxycycline

# doxycycline 100mg online https://doxycyline1st.com/
order doxycycline online 2022/02/26 9:49 Jusidkid

doxycycline 100mg online https://doxycyline1st.com/
order doxycycline online

# lasix generic https://buylasix.icu/
lasix side effects 2022/06/24 17:16 LasixRx

lasix generic https://buylasix.icu/
lasix side effects

# clomiphene online https://clomidonline.icu/ 2022/07/08 13:44 Clomidj

clomiphene online https://clomidonline.icu/

# ivermectin for heartworm https://stromectolbestprice.com/ 2022/07/30 0:38 BestPrice

ivermectin for heartworm https://stromectolbestprice.com/

# best male enhancement pills https://ed-pills.xyz/
non prescription ed pills 2022/09/16 19:45 EdPills

best male enhancement pills https://ed-pills.xyz/
non prescription ed pills

# Best and news about drug. Best and news about drug.
https://edonlinefast.com
Get here. Actual trends of drug. 2023/02/17 16:36 EdPills

Best and news about drug. Best and news about drug.
https://edonlinefast.com
Get here. Actual trends of drug.

# Read now. Best and news about drug.
https://edonlinefast.com
Drug information. Get information now. 2023/02/18 4:08 EdPills

Read now. Best and news about drug.
https://edonlinefast.com
Drug information. Get information now.

# ed meds online canada 2023/02/21 8:52 EdgarIneks

Best and news about drug. What side effects can this medication cause?
https://canadianfast.com/# cheap pet meds without vet prescription
Learn about the side effects, dosages, and interactions. Read now.

# ロレックス デイトジャスト ピンクシェル ダイヤ 2023/03/10 11:57 uaikzryzlqu@ezwen.ne.jp

どちらも新品同様のお品で価格は驚きの安さ!
梱包も過剰でなく丁寧で商品をとても大切にされている気持ちが伝わります。
手書きのお手紙も入っていて、またお世話になりたいと思いました。
ロレックス デイトジャスト ピンクシェル ダイヤ https://www.2bcopy.com/product/product.aspx-id=2158.htm

# doxycycline tablets - https://doxycyclinesale.pro/# 2023/04/22 4:02 Doxycycline

doxycycline tablets - https://doxycyclinesale.pro/#

# buy cytotec in usa - https://cytotecsale.pro/# 2023/04/29 4:39 Cytotec

buy cytotec in usa - https://cytotecsale.pro/#

# over the counter ed medication https://overthecounter.pro/# 2023/05/08 22:43 OtcJikoliuj

over the counter ed medication https://overthecounter.pro/#

# over the counter steroid cream 2023/05/10 19:58 TommyAmora

https://overthecounter.pro/# over the counter uti meds

# over the counter blood thinners 2023/05/12 9:30 Gregorysew

https://overthecounter.pro/# over the counter anti inflammatories

# ed dysfunction treatment 2023/05/14 10:53 MichaelExcup

https://edpills.pro/# top rated ed pills

# erectile dysfunction pills 2023/05/15 3:50 MichaelExcup

http://edpills.pro/# treatment for ed

# cheap ed pills 2023/05/15 12:09 Mickeynix

https://edpills.pro/# buy ed pills

# ed treatments 2023/05/15 20:42 MichaelExcup

https://edpills.pro/# erection pills online

# compare prednisone prices https://prednisonepills.pro/# - prednisone steroids 2023/06/05 5:18 Prednisone

compare prednisone prices https://prednisonepills.pro/# - prednisone steroids

# purchase cytotec 2023/06/05 22:25 Davidodota

https://cytotecpills.pro/# order cytotec online

# canadian pharmacies that deliver to the us 2023/06/06 9:40 JosephBab

http://prednisonepills.pro/# prednisone price south africa

# Misoprostol 200 mg buy online 2023/06/07 5:48 Davidodota

https://cytotecpills.pro/# how to get cytotec online

# over the counter erectile dysfunction pills 2023/06/09 16:59 BennySpuse

http://edpillsfd.com/# ed remedies

# sildenafil 10 mg daily 2023/06/28 7:54 DavidPaync

https://edpill.pro/# mens ed pills

# sildenafil 100 capsules 2023/06/28 22:59 DavidPaync

http://sildenafilpills.pro/# sildenafil best price canada

# sildenafil generic india 2023/06/29 13:13 DavidPaync

http://sildenafilpills.pro/# purchase sildenafil 100 mg

# Paxlovid over the counter https://paxlovid.pro/# - paxlovid cost without insurance 2023/07/03 3:57 Paxlovid

Paxlovid over the counter https://paxlovid.pro/# - paxlovid cost without insurance

# ロレックス 偽物 ヴィトン 2023/07/08 18:29 vzfhelkqf@ocn.ne.jp

この度は迅速な発送と丁寧な梱包でありがとう
ございました。
そして商品についても予想以上にきれいな物で嬉しい驚きでした
★グッチ グッチ★ジャッキーバッグ★セミショルダーバッグ★00963★GGデニム×カーフ★ブラック/黒★
こんなお値段だし・・・とたいした期待は持たずに購入したのですが、良い意味での期待を大
きく裏切るような綺麗な商品が届いて驚きました。
バックもお財布も早速活用しています。
かなりお買い得気分です。
また利用したいと思います。
ありがとうございました。
ロレックス 偽物 ヴィトン https://www.gmt78.com/product/detail/5755.htm

# buy paxlovid online https://paxlovid.store/
paxlovid price 2023/07/13 21:41 Paxlovid

buy paxlovid online https://paxlovid.store/
paxlovid price

# Paxlovid over the counter https://paxlovid.life/# paxlovid for sale 2023/07/26 6:15 Paxlovid

Paxlovid over the counter https://paxlovid.life/# paxlovid for sale

# buying ed pills online https://edpills.ink/# - ed pills online 2023/07/27 0:50 EdPills

buying ed pills online https://edpills.ink/# - ed pills online

# cytotec online https://cytotec.ink/# - buy cytotec online 2023/07/27 1:12 PillsFree

cytotec online https://cytotec.ink/# - buy cytotec online

# bbw dating sites 2023/08/09 18:28 WayneGurry

flirting dating site: http://datingtopreview.com/# - best web dating site

# buy cytotec pills 2023/08/25 3:15 Georgejep

https://misoprostol.guru/# п»?cytotec pills online

# migliori farmacie online 2023 2023/09/25 4:57 Archieonelf

http://farmaciaonline.men/# acquisto farmaci con ricetta

# comprare farmaci online all'estero 2023/09/26 6:11 Archieonelf

http://onlineapotheke.tech/# online apotheke gГ?nstig

# versandapotheke deutschland 2023/09/27 1:30 Williamreomo

https://onlineapotheke.tech/# versandapotheke
online apotheke deutschland

# п»їonline apotheke 2023/09/27 2:59 Williamreomo

https://onlineapotheke.tech/# online apotheke versandkostenfrei
gГ?nstige online apotheke

# internet apotheke 2023/09/27 4:46 Williamreomo

https://onlineapotheke.tech/# п»?online apotheke
versandapotheke deutschland

# online apotheke gГјnstig 2023/09/27 5:11 Williamreomo

http://onlineapotheke.tech/# online apotheke versandkostenfrei
versandapotheke deutschland

# gГјnstige online apotheke 2023/09/27 6:02 Williamreomo

http://onlineapotheke.tech/# versandapotheke deutschland
online apotheke deutschland

# farmacia online miglior prezzo 2023/09/27 6:11 Archieonelf

https://farmaciabarata.pro/# farmacia barata

# online apotheke preisvergleich 2023/09/27 9:22 Williamreomo

https://onlineapotheke.tech/# online apotheke deutschland
versandapotheke deutschland

# п»їonline apotheke 2023/09/27 10:10 Williamreomo

https://onlineapotheke.tech/# online apotheke deutschland
versandapotheke deutschland

# п»їonline apotheke 2023/09/27 16:17 Terrywef

acheter sildenafil 100mg sans ordonnance

# buying pharmaceuticals from canada 2023/10/17 1:42 Dannyhealm

The staff always goes the extra mile for their customers. https://mexicanpharmonline.com/# mexico drug stores pharmacies

# buy prescription online 2023/10/17 5:25 Dannyhealm

Top-notch medications sourced globally. https://mexicanpharmonline.shop/# mexican pharmaceuticals online

# best mexican pharmacies 2023/10/17 18:59 Dannyhealm

They have a fantastic range of supplements. http://mexicanpharmonline.com/# mexican rx online

# www canadian pharmacies 2023/10/17 20:07 Dannyhealm

The team always ensures that I understand my medication fully. http://mexicanpharmonline.com/# mexican rx online

# canadian online drug store 2023/10/18 5:46 Dannyhealm

From greeting to checkout, always a pleasant experience. https://mexicanpharmonline.com/# mexico drug stores pharmacies

# buying prescription medications online 2023/10/18 9:53 Dannyhealm

Love their spacious and well-lit premises. https://mexicanpharmonline.com/# mexican rx online

# buy medications without prescriptions 2023/10/18 10:27 Dannyhealm

A beacon of international trust and reliability. https://mexicanpharmonline.shop/# mexican mail order pharmacies

# paxlovid generic 2023/10/26 23:20 LarryNef

https://stromectol.icu/# stromectol ivermectin buy

# ed pills cheap 2023/11/23 6:14 WilliamApomb

http://sildenafil.win/# lowest price for sildenafil 20 mg

# clomid cheap 2023/12/27 1:48 RaymondGrido

http://prednisone.bid/# prednisone price south africa

# where buy clomid pills 2023/12/30 23:08 Stephendep

https://clomid.site/# can i buy clomid prices

# 200 mg doxycycline 2024/01/06 14:56 BobbyHef

http://doxycyclinebestprice.pro/# 100mg doxycycline

# best pills for ed 2024/01/09 0:34 CharlesDioky

https://edpillsdelivery.pro/# online ed medications

# comprare farmaci online con ricetta 2024/01/15 18:06 Wendellglaks

http://farmaciaitalia.store/# farmacie online sicure

# farmacia online piГ№ conveniente 2024/01/15 21:51 Walterpoume

http://tadalafilitalia.pro/# п»?farmacia online migliore

# farmacie online autorizzate elenco 2024/01/16 21:53 Wendellglaks

http://farmaciaitalia.store/# farmacia online migliore

# clomid without insurance 2024/01/21 10:41 LarryVoP

What side effects can this medication cause? https://cytotec.directory/# buy cytotec pills online cheap

# tamoxifen for sale 2024/01/22 0:00 Normantug

https://clomidpharm.shop/# buying cheap clomid

# where can i buy clomid pills 2024/01/22 8:46 LarryVoP

Their health awareness campaigns are so informative https://cytotec.directory/# purchase cytotec

# tamoxifen endometriosis 2024/01/22 11:41 Normantug

http://prednisonepharm.store/# prednisolone prednisone

# ivermectin price usa 2024/01/31 10:05 Andrewamabs

https://prednisonetablets.shop/# prednisone cost canada

# zestril 10 mg price 2024/02/23 15:45 Charlesmax

https://furosemide.guru/# lasix 20 mg

# zestril 20 mg tab 2024/02/26 8:49 Charlesmax

https://buyprednisone.store/# otc prednisone cream

# lightdatings life 2024/03/03 0:45 Thomasjax

https://angelawhite.pro/# Angela White izle

# dating service hotmail south africa 2024/03/03 2:59 RodrigoGrany

https://evaelfie.pro/# eva elfie izle

# senior singles chat 2024/03/03 10:12 Thomasjax

https://abelladanger.online/# abella danger izle

# date online 2024/03/04 15:07 Thomasjax

http://abelladanger.online/# abella danger izle

# vip dating now 2024/03/04 19:06 Thomasjax

https://sweetiefox.online/# Sweetie Fox izle

# find singles dating 2024/03/05 17:19 RodrigoGrany

http://evaelfie.pro/# eva elfie izle

# searchingforsingles 2024/03/07 14:40 HowardBox

a dating site: https://evaelfie.site/# eva elfie videos

# aduilt dating 2024/03/09 5:18 HowardBox

asian dating: http://sweetiefox.pro/# sweetie fox video

# dating gmail germany 2024/03/10 0:55 HowardBox

dating service hotmail south africa: http://miamalkova.life/# mia malkova videos

# can i buy generic clomid without insurance 2024/04/04 1:52 Robertsuela

http://prednisoneall.shop/# prednisone buy online nz

# where can i buy generic clomid 2024/04/05 13:27 Robertsuela

https://amoxilall.com/# amoxil generic

# Buy Tadalafil 5mg 2024/04/07 5:00 JohnnieZet

http://sildenafiliq.com/# Sildenafil 100mg price

# buy cheap doxycycline 2024/04/12 0:34 Archiewef

https://diflucan.icu/# diflucan pills online

# buy doxycycline online 270 tabs 2024/04/13 16:57 Archiewef

https://diflucan.icu/# diflucan 150 mg capsule

タイトル
名前
URL
コメント