マイナーでもいいよね??

殆どVB系、でも .NET じゃない VB は知らないよん

目次

Blog 利用状況

書庫

日記カテゴリ

プリンタ用のクラス(VB)

サンプルアプリのライブラリ側にプリンタのクラスを追加しました。

プリンタを表すクラス PrintQueue クラスは DomainObject クラスを継承します。

そして Webアプリでデータソースとして使えるようにします。

 

<DataObject()>

Public NotInheritable Class PrintQueue

  Inherits DomainObject

 

#Region " プライベートフィールド "

  Private ReadOnly _name, _server As String

#End Region

 

#Region " フレンドコンストラクタ "

  'DirectoryEntry を指定して PrintQueue クラスの新しいインスタンスを初期化します。

  Friend Sub New(entry As DirectoryEntry)

    MyBase.New(entry)

    _name = entry.Properties.Item("printerName").Value.ToString()

    _server = entry.Properties.Item("serverName").Value.ToString()

  End Sub

#End Region

 

#Region " パブリックプロパティ "

  'カラーかどうかを取得または設定します。

  Public Property Color As Boolean

    Get

      If MyBase.IsDisposed Then

        Throw New ObjectDisposedException(Me.GetType().Name)

      End If

      Return Convert.ToBoolean(MyBase.Entry.Properties.Item("printColor").Value)

    End Get

    Set(value As Boolean)

      If MyBase.IsDisposed Then

        Throw New ObjectDisposedException(Me.GetType().Name)

      End If

      MyBase.Entry.Properties.Item("printColor").Value = value

    End Set

  End Property

※以降の DirectoryEntry を参照するプロパティの Dispose チェックは省略します。

  '両面かどうかを取得または設定します。

  Public Property Duplex As Boolean

    Get

      Return Convert.ToBoolean(MyBase.Entry.Properties.Item("printDuplexSupported").Value)

    End Get

    Set(value As Boolean)

      MyBase.Entry.Properties.Item("printDuplexSupported").Value = value

    End Set

  End Property

 

  '名前を取得します。

  Public ReadOnly Property FullName As String

    Get

      Return MyBase.Name

    End Get

  End Property

 

  '場所を取得または設定します。

  Public Property Location As String

    Get

      Return DirectCast(MyBase.Entry.Properties.Item("location").Value, String)

    End Get

    Set(value As String)

      MyBase.Entry.Properties.Item("location").Value = value

    End Set

  End Property

 

  '最高解像度を取得または設定します。

  Public Property MaxResolution As Integer?

    Get

      Return DirectCast(MyBase.Entry.Properties.Item("printMaxResolutionSupported").Value, Integer?)

    End Get

    Set(value As Integer?)

      MyBase.Entry.Properties.Item("printMaxResolutionSupported").Value = value

    End Set

  End Property

 

  'モデルを取得または設定します。

  Public Property Model As String

    Get

      Return DirectCast(MyBase.Entry.Properties.Item("driverName").Value, String)

    End Get

    Set(value As String)

      MyBase.Entry.Properties.Item("driverName").Value = value

    End Set

  End Property

 

  'プリンタ名を取得します。

  Public Overrides ReadOnly Property Name As String

    Get

      Return _name

    End Get

  End Property

 

  'サーバ名を取得します。

  Public ReadOnly Property ServerName As String

    Get

      Return _server

    End Get

  End Property

 

  '印刷速度を取得または設定します。

  Public Property Speed As Integer?

    Get

      Return DirectCast(MyBase.Entry.Properties.Item("printPagesPerMinute").Value, Integer?)

    End Get

    Set(value As Integer?)

      MyBase.Entry.Properties.Item("printPagesPerMinute").Value = value

    End Set

  End Property

 

  'ホチキス止めかどうかを取得または設定します。

  Public Property Stapling As Boolean

    Get

      Return Convert.ToBoolean(MyBase.Entry.Properties.Item("printStaplingSupported").Value)

    End Get

    Set(value As Boolean)

      MyBase.Entry.Properties.Item("printStaplingSupported").Value = value

    End Set

  End Property

#End Region

 

#Region " パブリックメソッド "

  '指定した名前のプリンタを検索します。このメソッドはデータバインド用です。

  <DataObjectMethod(DataObjectMethodType.Select)>

  Public Shared Function FindByName(name As String) As PrintQueue

    Return DirectCast(DirectoryAccess.FindDirectoryObject(name, CategoryType.PrintQueue), PrintQueue)

  End Function

 

  'プリンタの一覧を取得します。このメソッドはデータバインド用です。

  <DataObjectMethod(DataObjectMethodType.Select)>

  Public Shared Function GetPrintQueues() As IList(Of PrintQueue)

    Return DirectoryAccess.GetPrintQueues()   'プリンタを取得

  End Function

#End Region

End Class

 

Name プロパティは継承元が name 属性の値を返すようになってます。

プリンタの場合、プリンタのプロパティ画面の項目と属性の対応(全般タブ)で書いた通りプリンタ名を返したいので、printerName 属性の値を返すようオーバーライドしてます。

そして FullName プロパティが name 属性の値を返すようにしてます。

 

データバインド用のメソッドは Webアプリで必要になります。内部で DirectoryAccess クラスのメソッドを呼んでますが、これについては別途書きます。

投稿日時 : 2014年1月4日 0:31

コメントを追加

# JDaOafmxRkJwdVPnY 2021/07/03 4:05 https://www.blogger.com/profile/060647091882378654

Wanted posting. Loads of excellent writing here. I wish I saw it found the site sooner. Congrats!

# Illikebuisse gwptp 2021/07/05 3:12 pharmacepticacom

hcos pill https://pharmaceptica.com/

# stromectol ivermectin buy http://stromectolabc.com/
stromectol cream 2022/02/07 17:13 Busjdhj

stromectol ivermectin buy http://stromectolabc.com/
stromectol cream

# buy ivermectin for humans uk http://stromectolabc.com/
stromectol 3mg 2022/02/08 10:07 Busjdhj

buy ivermectin for humans uk http://stromectolabc.com/
stromectol 3mg

# buy doxycycline online https://doxycyline1st.com/
doxycycline 100 mg 2022/02/25 21:59 Doxycycline

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

# smrejyxsszgc 2022/06/03 5:15 ohqrhdhy

https://erythromycin1m.com/# erythromycin eye ointment dosage

# custom writing essay x78dud 2022/09/03 22:47 Charlosmox


Kudos, An abundance of facts.
https://definitionessays.com/ professional personal statement writers

# paxlovid near me https://paxlovid.best/
paxlovid cost 2022/09/07 22:28 Paxlovid

paxlovid near me https://paxlovid.best/
paxlovid cost

# how to write a professional essay q22szq 2022/09/08 22:33 Charlosmox

You actually mentioned that fantastically! https://definitionessays.com/ phd dissertation length

# prednisone 20 mg generic https://prednisone20mg.icu/ 2022/10/15 6:54 Prednisone

prednisone 20 mg generic https://prednisone20mg.icu/

# prednisone best price https://prednisone20mg.site/
brand prednisone 2022/11/15 10:46 Prednisone

prednisone best price https://prednisone20mg.site/
brand prednisone

# cheapest ed pills https://ed-pills.site/
cure ed 2022/11/17 15:50 EdPills

cheapest ed pills https://ed-pills.site/
cure ed

# chloroquine phosphate buy online usa 2022/12/26 6:05 MorrisReaks

ing chloroquine online http://www.hydroxychloroquinex.com/#

# argumentative essay for sale l196nj 2023/02/26 10:12 CharlesSnoff


Really quite a lot of superb tips!
can i pay someone to do my essay https://quality-essays.com/ buy a college essay

# best research paper writing service b88mxd 2023/02/28 23:04 StevenGrelo


Fantastic advice. Cheers!
paper writing service ivy professional https://service-essay.com/ buying papers

# writing a biography essay v123qw 2023/03/06 3:31 EugeneSib


You made the point.
college essay inspiration https://service-essay.com writing prompts for persuasive essays https://homeworkcourseworkhelps.com

# thesis page p355bv 2023/03/06 19:10 Gregorysaipt

You actually said that really well!
help with writing essay https://researchpaperwriterservices.com college essay promps https://researchpaperwriterservices.com

# writing an essay w732yv 2023/03/07 9:34 EugeneSib


Wow quite a lot of great information.
write a essay for me https://essaywritingservicebbc.com essay writing services recommendations https://helpwritingdissertation.com

# doctoral theses b19zhz 2023/03/08 1:26 EugeneSib


Good material, Thanks.
essay writing service review https://studentessaywriting.com psychology essay writing https://paperwritingservicecheap.com

# dissertion z10veg 2023/03/08 16:49 EugeneSib

You actually explained this adequately!
what is the best custom essay site https://phdthesisdissertation.com proposal for dissertation https://argumentativethesis.com

# writing your doctoral dissertation m38bub 2023/03/09 9:27 EugeneSib

You stated this effectively.
how to write expository essays https://helpmedomyxyzhomework.com phd thesis search https://writinganessaycollegeservice.com

# how to write a visual analysis essay p31qqd 2023/03/10 11:14 Gregorysaipt

You actually stated this fantastically.
how to write thesis https://essaywritingservicebbc.com good customer service essay https://essayssolution.com

# business letter writing service x46fjd 2023/03/10 14:29 EugeneSib


Well voiced of course. !
should college essays be double spaced https://bestonlinepaperwritingservices.com doctoral dissertations online https://bestpaperwritingservice.com

# dissertation proposal writing service s57fzt 2023/03/12 6:38 Gregorysaipt

You explained it exceptionally well!
essay writing service online https://dissertationwritingtops.com how to write a critical evaluation essay https://essaywritingserviceahrefs.com

# common college essays j84prt 2023/03/12 11:10 EugeneSib


Very well expressed genuinely. .
how to write a college essay https://payforanessaysonline.com english essay help online https://buycheapessaysonline.com

# writing a cause and effect essay x16wey 2023/03/13 1:44 EugeneSib


Amazing all kinds of helpful tips.
how long is a dissertation https://essayservicehelp.com how to write a cause and effect essay https://writingresearchtermpaperservice.com

# law essay writing service t36cnh 2023/03/13 4:24 Gregorysaipt


Cheers. I appreciate it!
dissertation help literature review https://essaypromaster.com professional article writing services https://topswritingservices.com

# writing essay scholarships j301ia 2023/03/13 16:20 EugeneSib


Cheers! Valuable information.
e dissertation https://essaywritingserviceahrefs.com essay writing service legit https://researchproposalforphd.com

# how to write a persuasive essay q99fkq 2023/04/02 9:50 EugeneSib


Thanks. I enjoy this.
writers wanted online https://essaywritingservicelinked.com essay online writer https://englishessayhelp.com

# 스포츠토토사이트 2023/04/19 14:13 https://www.avimograbi.com/

???????? https://www.avimograbi.com/ superb article. Thanks an excessive amount of for the breakdown you've got supplied here.

# dfsffsfdsf 2023/04/19 14:21 토토위젯검증커뮤니티

this internet web site, and i

# The plugins developed for WordPress 2023/05/09 23:16 Justas

The plugins developed for WordPress serve to enhance the features and functions of a WordPress website, allowing you to build your awesome and functional site https://t.me/wpigaming/648 Customise WordPress with powerful, professional and intuitive fields.

# re: プリンタ用のクラス(VB) 2023/08/03 7:29 먹튀신고

The whole time I was reading it, I was able to read it all the way through without getting bored. Shout out respect for your abilities.
https://totoward.com/

# re: プリンタ用のクラス(VB) 2023/08/04 7:34 먹튀검증

hi! I look forward to seeing your posts on the blog and looking forward to good results. If you also want something good to happen, I hope you come here to play. I'll be waiting.
https://totoghost.com/

# re: プリンタ用のクラス(VB) 2023/10/18 12:00 토토사이트

It is extremely beneficial, alternatively it could be essential to be able to examine making use of website =) https://meoktwi.com/

# re: プリンタ用のクラス(VB) 2023/10/18 12:02 먹튀검증

I will state only that it really is outstanding! The blog is normally details as well as typically help make great aspects. https://therowdylender.com/

# re: プリンタ用のクラス(VB) 2023/10/18 12:03 토토사이트

It is enjoyable, however it is important that you check out this amazing web site =) https://totogorae.com/

# re: プリンタ用のクラス(VB) 2023/10/18 12:05 https://mymelee.com/

Helped to getting in touch with game playing in this posting fully grasp every little thing pertaining to all people =) https://mymelee.com/

# Plavix generic price https://plavix.guru/ buy plavix 2023/10/23 16:40 Plavixxx

Plavix generic price https://plavix.guru/ buy plavix

# acquistare farmaci senza ricetta https://farmaciait.pro/ farmacia online migliore 2023/12/04 3:38 Farmacia

acquistare farmaci senza ricetta https://farmaciait.pro/ farmacia online migliore

# prednisone 10 mg over the counter https://prednisone.bid/ prednisone 5 tablets 2023/12/27 2:26 Prednisone

prednisone 10 mg over the counter https://prednisone.bid/ prednisone 5 tablets

タイトル
名前
URL
コメント