Click here to Skip to main content
15,898,222 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVB.Net Print Queue Enumeration Pin
SQLDiablo17-Apr-07 5:47
SQLDiablo17-Apr-07 5:47 
GeneralRe: VB.Net Print Queue Enumeration Pin
SQLDiablo17-Apr-07 5:49
SQLDiablo17-Apr-07 5:49 
GeneralRe: VB.Net Print Queue Enumeration Pin
Tarakeshwar Reddy17-Apr-07 6:01
professionalTarakeshwar Reddy17-Apr-07 6:01 
AnswerRe: VB.Net Print Queue Enumeration Pin
Tim Carmichael17-Apr-07 6:03
Tim Carmichael17-Apr-07 6:03 
GeneralRe: VB.Net Print Queue Enumeration Pin
SQLDiablo18-Apr-07 2:53
SQLDiablo18-Apr-07 2:53 
GeneralRe: VB.Net Print Queue Enumeration Pin
SQLDiablo18-Apr-07 3:16
SQLDiablo18-Apr-07 3:16 
GeneralRe: VB.Net Print Queue Enumeration Pin
Tim Carmichael18-Apr-07 3:28
Tim Carmichael18-Apr-07 3:28 
QuestionRe: VB.Net Print Queue Enumeration Pin
SQLDiablo18-Apr-07 7:14
SQLDiablo18-Apr-07 7:14 
Ok, I almost have it working, except I'm now get a NullReferenceException error (Object not set to an instance of an object) on the line marked with a "-->". The error is directly following this paragraph, and my sub procedure is below the error. I call the sub like this: GetPrinters("name-of-server"). If you could help me out, I'd really appreciate it.

Error details:

<br />
System.NullReferenceException was unhandled<br />
  Message="Object reference not set to an instance of an object."<br />
  Source="ResHelp Troubleshooter"<br />
  StackTrace:<br />
       at ResHelp.frmAddPrinter.GetPrinters(String strServer) in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\frmAddPrinter.vb:line 68<br />
       at ResHelp.frmAddPrinter.lbxServer_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\frmAddPrinter.vb:line 80<br />
       at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)<br />
       at System.Windows.Forms.ListBox.WmReflectCommand(Message& m)<br />
       at System.Windows.Forms.ListBox.WndProc(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
       at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)<br />
       at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)<br />
       at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)<br />
       at System.Windows.Forms.Control.WmCommand(Message& m)<br />
       at System.Windows.Forms.Control.WndProc(Message& m)<br />
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)<br />
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)<br />
       at System.Windows.Forms.Form.WndProc(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
       at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)<br />
       at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)<br />
       at System.Windows.Forms.Control.DefWndProc(Message& m)<br />
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
       at System.Windows.Forms.Control.WndProc(Message& m)<br />
       at System.Windows.Forms.ListBox.WndProc(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)<br />
       at System.Windows.Forms.Form.ShowDialog()<br />
       at ResHelp.frmMain.btnGo_Click(Object sender, EventArgs e) in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\frmMain.vb:line 15<br />
       at System.Windows.Forms.Control.OnClick(EventArgs e)<br />
       at System.Windows.Forms.Button.OnClick(EventArgs e)<br />
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br />
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
       at System.Windows.Forms.Control.WndProc(Message& m)<br />
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)<br />
       at System.Windows.Forms.Button.WndProc(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)<br />
       at System.Windows.Forms.Form.ShowDialog()<br />
       at ResHelp.modMain.main() in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\modMain.vb:line 11<br />
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)<br />
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()<br />
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)<br />
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)<br />
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()<br />
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
       at System.Threading.ThreadHelper.ThreadStart()<br />


VB Code to the sub procedure:

<br />
    Private Sub GetPrinters(ByVal strServer As String)<br />
        Try<br />
            Dim connection As New ConnectionOptions<br />
            connection.Username = Me.txtUsername.Text<br />
            connection.Password = Me.txtPassword.Text<br />
            connection.Authority = "ntlmdomain:" + My.Settings.Item("domain").ToString<br />
<br />
            Dim scope As New ManagementScope("\\" + strServer + "\root\CIMV2", connection)<br />
            scope.Connect()<br />
<br />
            Dim query As New ObjectQuery("SELECT * FROM Win32_Printer")<br />
<br />
            Dim searcher As New ManagementObjectSearcher(scope, query)<br />
<br />
            Me.lbxPrinterShare.Items.Clear()<br />
<br />
            For Each queryObj As ManagementObject In searcher.Get()<br />
                'If Not (queryObj("ShareName").ToString = "''" Or queryObj("ShareName").ToString = "" Or queryObj("ShareName").ToString = Nothing) Then<br />
-->             Me.lbxPrinterShare.Items.Add(queryObj("ShareName").ToString)<br />
                'End If<br />
            Next<br />
        Catch err As ManagementException<br />
            MessageBox.Show("An error occurred while querying for WMI printer data: " & err.Message)<br />
        Catch unauthorizedErr As System.UnauthorizedAccessException<br />
            MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message)<br />
        End Try<br />
    End Sub<br />


DotCom
Help Desk Analyst
(programmer on the side)
AnswerRe: VB.Net Print Queue Enumeration Pin
Tim Carmichael18-Apr-07 7:31
Tim Carmichael18-Apr-07 7:31 
GeneralRe: VB.Net Print Queue Enumeration Pin
SQLDiablo18-Apr-07 7:52
SQLDiablo18-Apr-07 7:52 
AnswerRe: VB.Net Print Queue Enumeration Pin
SQLDiablo18-Apr-07 8:55
SQLDiablo18-Apr-07 8:55 
Questionhow to insert an image from VB to an access database Pin
EvScott17-Apr-07 4:12
EvScott17-Apr-07 4:12 
AnswerRe: how to insert an image from VB to an access database Pin
Sathesh Sakthivel17-Apr-07 5:27
Sathesh Sakthivel17-Apr-07 5:27 
Questiondesign the UI Pin
ciacia17-Apr-07 4:07
ciacia17-Apr-07 4:07 
AnswerRe: design the UI Pin
MatrixCoder17-Apr-07 5:18
MatrixCoder17-Apr-07 5:18 
Questionadd data to database Pin
peteyshrew17-Apr-07 4:03
peteyshrew17-Apr-07 4:03 
AnswerRe: add data to database Pin
Tarakeshwar Reddy17-Apr-07 4:52
professionalTarakeshwar Reddy17-Apr-07 4:52 
AnswerRe: add data to database Pin
manni_n17-Apr-07 6:56
manni_n17-Apr-07 6:56 
AnswerRe: add data to database Pin
klaydze17-Apr-07 21:48
klaydze17-Apr-07 21:48 
QuestionHow to run video file in vb.net windows application? Pin
balamurugan8217-Apr-07 3:50
balamurugan8217-Apr-07 3:50 
AnswerRe: How to run video file in vb.net windows application? Pin
MatrixCoder17-Apr-07 5:00
MatrixCoder17-Apr-07 5:00 
QuestionHow can we capture the incoming net send message in vb.net? Pin
vijay258317-Apr-07 3:39
vijay258317-Apr-07 3:39 
AnswerRe: How can we capture the incoming net send message in vb.net? Pin
Dave Kreskowiak17-Apr-07 7:19
mveDave Kreskowiak17-Apr-07 7:19 
QuestionSHDocVw.ShellWindows .Quit does not stop process Pin
SJR_117-Apr-07 2:41
SJR_117-Apr-07 2:41 
AnswerRe: SHDocVw.ShellWindows .Quit does not stop process Pin
Dave Kreskowiak17-Apr-07 6:43
mveDave Kreskowiak17-Apr-07 6:43 

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.