Click here to Skip to main content
15,914,109 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhow to know printer name if.. Pin
K edar V18-Sep-06 1:33
K edar V18-Sep-06 1:33 
AnswerRe: how to know printer name if.. Pin
Dave Kreskowiak18-Sep-06 7:36
mveDave Kreskowiak18-Sep-06 7:36 
GeneralRe: how to know printer name if.. Pin
K edar V18-Sep-06 18:43
K edar V18-Sep-06 18:43 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak19-Sep-06 2:05
mveDave Kreskowiak19-Sep-06 2:05 
GeneralRe: how to know printer name if.. Pin
K edar V19-Sep-06 2:13
K edar V19-Sep-06 2:13 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak19-Sep-06 6:34
mveDave Kreskowiak19-Sep-06 6:34 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak19-Sep-06 7:24
mveDave Kreskowiak19-Sep-06 7:24 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak19-Sep-06 7:41
mveDave Kreskowiak19-Sep-06 7:41 
Oh! Might help if I posted the code I'm using:
Imports System.Management
 
Public Class Form1
 
    ' Important!!  MUST use \root\cimv2 here!  \root\default does NOT work!
    Private scope as New ManagementScope(String.Format("\\{0}\root\cimv2", Environment.MachineName))
 
    Private Sub Button1_Click(blah, blah) Handles Button1.Click
        If ConnectToWmi() Then
            GetJobList()
        End If
    End Sub
 
    Private Sub GetJobList()
        ' Clear out the ListView we're using to show the jobs.
        JobList.Items.Clear()
 
        If scope.IsConnected Then
            Dim query As New ObjectQuery("SELECT * FROM Win32_PrintJob")
            Dim searcher As New ManagementObjectSearcher(scope, query)
 
            Dim objectCollection As ManagementObjectCollection = searcher.Get()
            For Each obj As ManagementObject In objectCollection
                JobList.Items.Add( new String() { CUint(obj("JobId")).ToString(), CStr(obj("Document")) } )
            Next
 
            ' It's very important to dispose these objects when your done with them!  If
            ' you don't, you'll end up with a handle leak and eventually crash the system.
            objectCollection.Dispose()
            searcher.Dispose()
        End If
    End Sub
 
    Private Function ConnectToWmi() As Boolean
        scope.Connect()
        Return scope.IsConnected()
    End Function
End Class



Dave Kreskowiak
Microsoft MVP - Visual Basic


GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak19-Sep-06 13:20
mveDave Kreskowiak19-Sep-06 13:20 
GeneralRe: how to know printer name if.. Pin
K edar V19-Sep-06 22:34
K edar V19-Sep-06 22:34 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak20-Sep-06 1:57
mveDave Kreskowiak20-Sep-06 1:57 
GeneralRe: how to know printer name if.. Pin
K edar V20-Sep-06 2:00
K edar V20-Sep-06 2:00 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak20-Sep-06 2:06
mveDave Kreskowiak20-Sep-06 2:06 
GeneralRe: how to know printer name if.. Pin
K edar V20-Sep-06 2:13
K edar V20-Sep-06 2:13 
GeneralRe: how to know printer name if.. Pin
Dave Kreskowiak20-Sep-06 4:49
mveDave Kreskowiak20-Sep-06 4:49 
Generalnot the solution but i've got problem(possible) Pin
K edar V20-Sep-06 23:36
K edar V20-Sep-06 23:36 
Questionflickr like TAGS Pin
navish0118-Sep-06 0:13
navish0118-Sep-06 0:13 
AnswerRe: flickr like TAGS Pin
Christian Graus18-Sep-06 0:37
protectorChristian Graus18-Sep-06 0:37 
Questionhow get the last modified date of the files Pin
Amit Agarrwal17-Sep-06 23:43
Amit Agarrwal17-Sep-06 23:43 
AnswerRe: how get the last modified date of the files Pin
me_vb_man17-Sep-06 23:47
me_vb_man17-Sep-06 23:47 
GeneralRe: how get the last modified date of the files Pin
Amit Agarrwal17-Sep-06 23:52
Amit Agarrwal17-Sep-06 23:52 
GeneralRe: how get the last modified date of the files Pin
me_vb_man17-Sep-06 23:55
me_vb_man17-Sep-06 23:55 
GeneralRe: how get the last modified date of the files Pin
Amit Agarrwal18-Sep-06 0:04
Amit Agarrwal18-Sep-06 0:04 
GeneralRe: how get the last modified date of the files Pin
me_vb_man18-Sep-06 0:08
me_vb_man18-Sep-06 0:08 
QuestionUrgent Code needed for remote database connection Pin
GabrielVarun17-Sep-06 23:30
GabrielVarun17-Sep-06 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.