Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
QuestionHelp needed for Active Directory code Pin
Lasse Fabricius9-Nov-05 21:49
Lasse Fabricius9-Nov-05 21:49 
QuestionDirect Crystal Printing to LPT port - Please Help Pin
Craig G Fraser9-Nov-05 21:10
Craig G Fraser9-Nov-05 21:10 
AnswerRe: Direct Crystal Printing to LPT port - Please Help Pin
Heath Stewart9-Nov-05 21:56
protectorHeath Stewart9-Nov-05 21:56 
GeneralRe: Direct Crystal Printing to LPT port - Please Help Pin
Craig G Fraser9-Nov-05 22:32
Craig G Fraser9-Nov-05 22:32 
GeneralRe: Direct Crystal Printing to LPT port - Please Help Pin
Heath Stewart9-Nov-05 22:38
protectorHeath Stewart9-Nov-05 22:38 
GeneralRe: Direct Crystal Printing to LPT port - Please Help Pin
Craig G Fraser9-Nov-05 23:20
Craig G Fraser9-Nov-05 23:20 
AnswerRe: Direct Crystal Printing to LPT port - Please Help Pin
Heath Stewart10-Nov-05 5:11
protectorHeath Stewart10-Nov-05 5:11 
GeneralRe: Direct Crystal Printing to LPT port - Please Help Pin
Craig G Fraser10-Nov-05 21:42
Craig G Fraser10-Nov-05 21:42 
Hi Heath,

Thanx for the info....had a look and boy that stuff is really confusing for me....Havent worked with calls to unmaganged code before so struggling to get my head around it and how to implement it in my code. I have managed to sort out the problem by creating a class using System.Management functionality.....Not sure if this is the best way but it works so will do for now....Does my class below look ok or do you tink it will cause problems ?

You really helped me to solve this so thanx a million...it really is appreciated..

Cheers

Craig

using System;<br />
using System.Management;<br />
using System.Collections;<br />
<br />
namespace VTG.Functions<br />
{<br />
	public class PrintFunctions<br />
	{<br />
		public struct PrinterInfo<br />
		{<br />
			public string sPrinterName;<br />
			public bool bShared;<br />
			public string sSharedName;<br />
			public string sServerName;<br />
			public string sPortName;<br />
			public bool bDefaultPrinter;<br />
		}<br />
<br />
		public static PrinterInfo[] GetPrintersCollection()<br />
		{<br />
			PrinterInfo[] pi = new PrinterInfo[10];<br />
			string searchQuery = "SELECT * FROM Win32_Printer";<br />
			ManagementObjectSearcher searchPrinters = <br />
				new ManagementObjectSearcher(searchQuery);<br />
			ManagementObjectCollection printerCollection = searchPrinters.Get();<br />
			int iPrinterIndex=0;<br />
			foreach(ManagementObject printer in printerCollection)<br />
			{<br />
				pi[iPrinterIndex].sPrinterName=printer.Properties["Name"].Value.ToString();<br />
				pi[iPrinterIndex].bShared=Convert.ToBoolean(printer.Properties["Shared"].Value);<br />
				if (pi[iPrinterIndex].bShared==true)<br />
				{<br />
					pi[iPrinterIndex].sSharedName=printer.Properties["ShareName"].Value.ToString();<br />
					pi[iPrinterIndex].sServerName=printer.Properties["ServerName"].Value.ToString();<br />
				}<br />
				pi[iPrinterIndex].sPortName=printer.Properties["PortName"].Value.ToString();<br />
				pi[iPrinterIndex].bDefaultPrinter=Convert.ToBoolean(printer.Properties["Default"].Value);<br />
<br />
				iPrinterIndex++;<br />
			}<br />
			return pi;<br />
		}<br />
	}<br />
}

QuestionDrawing Lines On A Form Pin
ytubis9-Nov-05 21:07
ytubis9-Nov-05 21:07 
AnswerRe: Drawing Lines On A Form Pin
Heath Stewart9-Nov-05 21:45
protectorHeath Stewart9-Nov-05 21:45 
QuestionNeed Help with .NET Pin
allenmpcx9-Nov-05 19:26
allenmpcx9-Nov-05 19:26 
AnswerRe: Need Help with .NET Pin
AETaylor10-Nov-05 22:14
AETaylor10-Nov-05 22:14 
QuestionDifferent Source Codes Pin
nosferatu20009-Nov-05 19:23
nosferatu20009-Nov-05 19:23 
AnswerRe: Different Source Codes Pin
Luis Alonso Ramos9-Nov-05 19:35
Luis Alonso Ramos9-Nov-05 19:35 
QuestionMaskedTextBox Problem ! Pin
Caio19859-Nov-05 17:42
Caio19859-Nov-05 17:42 
GeneralRe: MaskedTextBox Problem ! Pin
Heath Stewart9-Nov-05 22:11
protectorHeath Stewart9-Nov-05 22:11 
QuestionRetrieving an image data type Pin
SyedZubair9-Nov-05 17:39
SyedZubair9-Nov-05 17:39 
AnswerRe: Retrieving an image data type Pin
Heath Stewart9-Nov-05 21:59
protectorHeath Stewart9-Nov-05 21:59 
QuestionException-When minimized and restored Pin
cloudking119669-Nov-05 17:34
cloudking119669-Nov-05 17:34 
AnswerRe: Exception-When minimized and restored Pin
Heath Stewart9-Nov-05 22:09
protectorHeath Stewart9-Nov-05 22:09 
AnswerRe: Exception-When minimized and restored Pin
S. Senthil Kumar10-Nov-05 4:19
S. Senthil Kumar10-Nov-05 4:19 
QuestionClass that can read/modify private values of another class Pin
budidharma9-Nov-05 11:30
budidharma9-Nov-05 11:30 
AnswerRe: Class that can read/modify private values of another class Pin
Leslie Sanford9-Nov-05 11:50
Leslie Sanford9-Nov-05 11:50 
GeneralRe: Class that can read/modify private values of another class Pin
budidharma9-Nov-05 12:17
budidharma9-Nov-05 12:17 
GeneralRe: Class that can read/modify private values of another class Pin
Leslie Sanford9-Nov-05 12:21
Leslie Sanford9-Nov-05 12:21 

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.