|
where is ExitWindowsEx in the .NET Framework? I can't find it anywhere.
|
|
|
|
|
It isn't, you need to use P/Invoke; kyle posted to the wrong forum
[DllImport("user32.dll")]<br />
public external static bool ExitWindowsEx(uint uFlags, int dwReason);
Search through the Vc7\PlatformSDK\Include directory to get the constants needed for the paramters.
James
Simplicity Rules!
|
|
|
|
|
I did think I was in the C++ forum when I posted. Please accept my apology. Your answer was excellent and it made me question, is there a way to restart the computer using C# managed code?
Kyle
|
|
|
|
|
kyledunn wrote:
Please accept my apology.
No problems
kyledunn wrote:
is there a way to restart the computer using C# managed code?
AFAIK there isn't; I haven't run across one anyway.
James
Simplicity Rules!
|
|
|
|
|
It is very doable from WMI API wrapped in the .NET System.Managment namespace. You can reboot/shutdown the local or any other machine on the domain. Depending on the privileges you or your admin have set, your mileage will vary.
Regards
|
|
|
|
|
using System.Management;
.
.
.
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary = TRUE");
ManagementBaseObject inParams;
ManagementBaseObject outParams;
bool temp;
foreach (ManagementObject os in searcher.Get())
{
temp = os.Scope.Options.EnablePrivileges;
os.Scope.Options.EnablePrivileges = true;
inParams = os.GetMethodParameters("Reboot");
outParams = os.InvokeMethod("Reboot", inParams, null);
os.Scope.Options.EnablePrivileges = temp;
}
You can also specify Shutdown for the method...
|
|
|
|
|
i want to delete bmp from the hard(no specified location), is this possible!!!
|
|
|
|
|
Zzzz wrote:
no specified location
????????
But if you have a "specified location" then you can use FileSystemInfo to open a file and then use the member method Delete() to delete it.
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Zzzz wrote:
(no specified location)
You mean that the files location may change, is that correct? Or are you actually doing a search for the file each time to find the location?
Nick Parker
|
|
|
|
|
yeah that's what i meant, or we may say that at runtime i cannot specify the location, i can only know the filename..
|
|
|
|
|
The static File.Delete method
|
|
|
|
|
It's not a good idea to delete all bmps in a hard disk
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
surely i won't delete all the bitmaps from the hard.!!!!!!
|
|
|
|
|
Zzzz wrote:
surely i won't delete all the bitmaps from the hard.!!!!!!
Sorry I misunderstood the question.
I still havent understood what exectly you want to know!
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
it's okay
here what i want,
at runtime, some bitmaps will b generated but if something wrong happned, i'll have to delete these files, without knowing where they are, only their names, Got it, anyway thanx
|
|
|
|
|
Zzzz wrote:
some bitmaps will b generated
If you are doing the generation, surely you'd know the folder where it's being generated.
Zzzz wrote:
without knowing where they are, only their names
You can concatenate the folder where you generate them with their file names and pass this string to the File.Delete function
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
I fianly knew how to add c a mschart to my form but i still don't knwo how to deal with it, i want to label the axis and pass the array whose data will be represented, cananyone help me!?!
|
|
|
|
|
When I add a string to a RichTextBox like this one:
"Rickard Andersson: Hello to you too, dude!"
Then I want to make the "Rickard Andersson:" bold (yes, I'm making a chat program) to give it a nice look... but how to make it bold!?!?!?!?!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
This is my sample code:
private void btnBold_Click(object sender, System.EventArgs e)
{
Font oldFont;
Font newFont;
oldFont = this.rtfText.SelectionFont;
if (oldFont.Bold)
newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
else
newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold);
this.rtfText.SelectionFont = newFont;
this.rtfText.Focus();
}
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Where in this code does "Rickard Andersson:" being bold?
I don't realy understand it... but I haven't tried it yet...
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Never mind!
I have figured it out how you mean with your code!
Now I know how!
Thank you Mazy!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Thanks!
In fact, I have several user controls, each one with different controls inside. I would like to create a loop for each user control, to go through inside controls one by one, no matter how many in there, and what they are, try to set readonly to true, catch exceptions if there is no such property. But such as combobox, does not have this property, but I still need to set it to readonly, how can I do it, and do you think this loop methodoligy will work?
Thanks a lot!
chris#
|
|
|
|
|
I have an idea for a program that would run in the background and then, when the user presses the windows key (in any application), it would come to the foreground.
Anyone know how I can do this?
|
|
|
|
|
http://www.codeproject.com/useritems/nishhotkeys01.asp
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
How to make Combobox, Radio buttons (group) read only?
Thanks!
|
|
|
|