|
And in that service you can execute a small line of code...
System.Diagnostics.Process.Start("Shutdown", "-s -t 01");
this will shut down the computer . ..
|
|
|
|
|
Almost every motherboard has a jumper you can use, it's where they plug in the wires for the power switch on the outside of the case. Almost all of them function the same way as well, short the circuit, and it starts the shut down/power up sequence.
You can also control the power from the power supply tap to the motherboard, many power supplies also have their own power switch (usually much higher voltage) and there is a way to do it through the PCI bus as well. Going further out, you could also cut power to the entire system from the power cord.
In the end it really depends on how 'micro' the controller really is and what voltages you're dealing with. A 110 volt switch is probably a bad idea for hooking up to a motherboard jumper, however you could simply kill the power to a battery backup and let the system shut itself down. In the 12 volt range you could use one of the power supplies used for car based computers. If your running off the USB line, then the motherboard power switch is probably your best bet.
As others have mentioned:
System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
Will also turn the computer off.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
Hi guys, whats going on ?
I have a form called Form1, there's a button which I click and Form2 is opened, now I want to send a value from Form2 back to Form1
(I know how to do it from a form to a new form!)
thx
|
|
|
|
|
Use an event in Form2 that Form1 subscribes to. There's an example in my article here[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
One of the best way to pass some value is by overloading the constructor.
For e.g if you want to pass an integer id or something like that from form1 to form2.
you need to do is make a small function on form2 like :
public Form2(int id)
{
InitializeComponent();
this.ID = id;
}
And while opening the form2 in form1 you need to do is
Form2 frm = new Form2(3); //3 can be replaced by any variable.
frm.showdialog();
or
frm.show();
|
|
|
|
|
See, Form 2 is already open through Form 1 !!!
Form2 F2 = new Form2();
SelectedGrammarID = Convert.ToInt32(SelectedRow.Cells["GrammarID"].Value);
this.Close();
I want to send the value "SelectedGrammarID" back to form 1!!!!
now I select a value in form 2 and click on a button, it closes the form and then I want to send the value to a Variable in Form 1 (I don't open the form again because it's already open !!!!)
Mr.K
|
|
|
|
|
Like I said before, use an event!
Add a new class IDEventArgs with this code
using System;
public class IDEventArgs : EventArgs
{
private int _ID;
public IDEventArgs(int id)
{
_ID = id;
}
public int ID
{
get { return _ID; }
}
} Add this to Form2
public event EventHandler<IDEventArgs> GrammarIDSelected;
private void CompleteFormProcessing()
{
OnGrammarIDSelected(new IDEventArgs(
Convert.ToInt32(SelectedRow.Cells["GrammarID"].Value)));
Close();
}
protected virtual void OnGrammarIDSelected(IDEventArgs e)
{
EventHandler<IDEventArgs> eh = GrammarIDSelected;
if (eh != null)
eh(this, e);
} Call CompleteFormProcessing from wherever you need it.
In Form1 add these.
Form2 F2 = new Form2();
F2.GrammarIDSelected += new EventHandler<IDEventArgs>(F2_GrammarIDSelected);
F2.Show();
void F2_GrammarIDSelected(object sender, IDEventArgs e)
{
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I'm just curious, is there a way to build an executable that will run on a computer that doesn't have the .NET framework installed?
i know that we can package our exe with dotnet framework which will install framework before installation.
but is their any solution without installing .
something like when we create exe thru vc++ compiler.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Easy, don't use a .NET language.
There are some cheats to package the entire framework with the program and then Not install it but do some other magic, but IMO that's even worse then telling users to download/install the .NET framework (would they like a 100MB+ program that needs only be 1 - 5MB? I don't think so)
Or maybe Mono's "full static compilation" will work also? I don't know.
Maybe cr88192's project will do this..? Not too much is known about it..
|
|
|
|
|
There are products out there that will do something like this, but they all cost big money. There are no free ones that do this.
|
|
|
|
|
As Dave said, products do exist but they are expensive, google for xenocode postbuild and you will have one such example.
|
|
|
|
|
Xenocode[^] will create an executable that doesn't need the framework to run. Your apps still delivered in MSIL and running .net code though, the needed parts of the framework and CSC.exe are embedded with your original app into the file you deliver. This results in a large 20-30mb executable even for small apps.
The RemoteSoft[^] linker and mini-deployment tool will convert your app into native code, so that there's no MSIL in your delivered files. The current version doesn't embed any of the native dlls from the framework that you use into the executable, so you have a series of folders with 20-30megs of them (possibly more). If you use XML serialization the automatically created IO classes will still be generated as managed code. I've played with this (and may be getting a copy for work); my big concern at the moment is that the author has been very poor about responding to email queries. If everything works more or less out of the box (it appears to at present) it shouldn't be an issue, but I'm worried about what if any major problems turn up.
VMware offers a similar product but it's ~$5k vs ~1k for the other two and AFAIK functions at the same level as xenocode.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I am astounded that people ask this still. Yes, there's a /NOFRAMEWORK switch on the compiler, we just don't use it b/c we like to make people download the framework.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
In my case DLing the framework has had nothing to do with it. We made a app for X several years ago. X wants us to make a version of it for Y, but is freaking over the reverse engineering risks. This is a CheaperThanAC++Port option for us. (NTM my experiance with MFC and C++ more generally is limited to messing around as a student years ago so there'd be a major learning curve involved).
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
So , if i compile with /NOFRAMEWORK in my machine and run that exe in another machine that doesn't have framework, will that exe run.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Congratulations!
Your response has reached position 26 in a Google search for NOFRAMEWORK. A sterling effort.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
This /NOFRAMEWORK option is not available in csc.exe, i don't know y u have given me this suggestion.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
plz help me . i want to insert data from excel sheet in web form . this web form should automatically take data from execl sheet.
can u plz tell me the library and function i should use .
can this be possible or not.
thanks in advance
|
|
|
|
|
Have a look at this.[^]
hmmm pie
|
|
|
|
|
thz for the kind help. well it helped me in some way but i want that my web page keep on getting data from this excel sheet .
|
|
|
|
|
I wanna convert image to vector but not vector file (.ai) same image with same format I mean clean all shadow and thing like it or have clear image with only some clear shape like circle ... or like cutout filter in photoshop in other way Can we use photoshop filter in our program.
|
|
|
|
|
An image can not simple be a vector format. a vector image as you may know is more like a series of instructions that are executed to draw the image. as this is the case you need a specific program that understands these 'instructions' and can render the image appropraitely.
I think what you want to do is look at image processing techniques. Im sure it would'nt take much of your time to do a search, i bet all the photoshop filter algorithms are floating around the internet somewhere.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
I've suddenly started getting an incomprehensible threading error message when I try to use the standard open-file dialog:
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
But my Main method DOES have "[STAThread]" preceding it. The online help goes into extensive detail on the complexities of apartment models, but doesn't give me a clue what could be causing this exception. Any ideas? Thanks!
|
|
|
|
|
And is the code launching the dialog running on the UI thread?
|
|
|
|
|
Yes; there is only one thread, which is started by the Application.Run () method from Main ().
|
|
|
|