Click here to Skip to main content
16,020,182 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to use SetForegroundWindow in C#...?? Pin
Heath Stewart11-Mar-04 4:42
protectorHeath Stewart11-Mar-04 4:42 
GeneralRe: How to use SetForegroundWindow in C#...?? Pin
Member 94012511-Mar-04 15:58
Member 94012511-Mar-04 15:58 
GeneralRe: How to use SetForegroundWindow in C#...?? Pin
Heath Stewart12-Mar-04 2:58
protectorHeath Stewart12-Mar-04 2:58 
QuestionHow to serialize static variables of a class ? Pin
Eric Marchesin10-Mar-04 21:54
Eric Marchesin10-Mar-04 21:54 
AnswerRe: How to serialize static variables of a class ? Pin
Daniel Turini11-Mar-04 2:55
Daniel Turini11-Mar-04 2:55 
GeneralRe: How to serialize static variables of a class ? Pin
Eric Marchesin11-Mar-04 4:44
Eric Marchesin11-Mar-04 4:44 
GeneralRe: How to serialize static variables of a class ? Pin
Daniel Turini11-Mar-04 6:14
Daniel Turini11-Mar-04 6:14 
QuestionHow to set defaultprinter Pin
yu-yu10-Mar-04 21:01
yu-yu10-Mar-04 21:01 
Hello,

Now I try to change default printer using C#.
After my investigation, I found it use WMI.
I used to WMI (Win32_Printer), but I couldn't.
The following is the source.
Please advice me.

best regards,
yu-yu

ManagementPath path = new ManagementPath();
ManagementBaseObject inParams = null;
ManagementBaseObject outParams = null;
string[] stemp = PrinterID.Split("\\".ToCharArray(), 8);
path.Server = stemp[2];
path.NamespacePath = @"root\CIMV2";
string relPath = string.Format("Win32_Printer.DeviceID='{0}'",PrinterID);
path.RelativePath = relPath;
try
{
ManagementObject mo = new ManagementObject(path);
outParams = mo.InvokeMethod("SetDefaultPrinter", inParams, null);
Console.WriteLine("Printer {0} is default now ", PrinterID);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}

AnswerRe: How to set defaultprinter Pin
Heath Stewart11-Mar-04 4:04
protectorHeath Stewart11-Mar-04 4:04 
GeneralRe: How to set defaultprinter Pin
yu-yu11-Mar-04 15:57
yu-yu11-Mar-04 15:57 
GeneralRe: How to set defaultprinter Pin
Heath Stewart12-Mar-04 2:56
protectorHeath Stewart12-Mar-04 2:56 
GeneralRe: How to set defaultprinter Pin
yu-yu12-Mar-04 5:10
yu-yu12-Mar-04 5:10 
GeneralRe: How to set defaultprinter Pin
Heath Stewart12-Mar-04 5:15
protectorHeath Stewart12-Mar-04 5:15 
GeneralRe: How to set defaultprinter Pin
yu-yu14-Mar-04 16:43
yu-yu14-Mar-04 16:43 
QuestionTextbox input Focus? Pin
Reinier van de Wetering10-Mar-04 20:42
Reinier van de Wetering10-Mar-04 20:42 
AnswerRe: Textbox input Focus? Pin
Syed Abdul Khader11-Mar-04 1:56
Syed Abdul Khader11-Mar-04 1:56 
GeneralError Finding right SqlCollation !! Pin
MasudM10-Mar-04 20:23
MasudM10-Mar-04 20:23 
GeneralRe: Error Finding right SqlCollation !! Pin
Heath Stewart11-Mar-04 4:00
protectorHeath Stewart11-Mar-04 4:00 
GeneralRe: Error Finding right SqlCollation !! Pin
MasudM11-Mar-04 4:31
MasudM11-Mar-04 4:31 
GeneralDynamically-created assemblies from run-time compiled code Pin
Nathan Ridley10-Mar-04 19:28
Nathan Ridley10-Mar-04 19:28 
GeneralRe: Dynamically-created assemblies from run-time compiled code Pin
Nathan Ridley10-Mar-04 19:52
Nathan Ridley10-Mar-04 19:52 
GeneralUsing C# controls in MFC Pin
Jain Mohit10-Mar-04 18:49
Jain Mohit10-Mar-04 18:49 
GeneralRe: Using C# controls in MFC Pin
Heath Stewart11-Mar-04 3:53
protectorHeath Stewart11-Mar-04 3:53 
GeneralSimple calculation problem with decimal value drivin me NUTS!!!! Pin
ASGill10-Mar-04 18:11
ASGill10-Mar-04 18:11 
GeneralRe: Simple calculation problem with decimal value drivin me NUTS!!!! Pin
MasudM10-Mar-04 20:15
MasudM10-Mar-04 20:15 

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.