|
I have been trying to detect when the power button has been pressed on a system (winXP) however so far i have been unsuccessful. I have tried useing WMI and monitoring the Win32_PowerManagementEvent but i only seem to be able to pick up a battery insertion/removal on a laptop and on a desktop it doesn't pick up anything. Is it actually possible to detect the button press and if so can some one point me in the direction of how to do it?
Thanks for any assistance offered,
P
|
|
|
|
|
Well, no. You could make your application detect an abnormal program exit by setting a value in a data file when the program starts, and then un-setting it when the program exists normally, and performing a specific task depending on the presence/absence of that setting. Consider that the user could just hit the hard reset button as well, so technically, the machine has been turned off and then back on.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks for your reply, the system is used a vehicle pc, the psu is connected to the power switch so when the engine is switched off the system is shut down to prevent flattening the battery. The reason i want to do this is to finish off the tasks being performed before the system shuts off
if this is not possible what alternatives are available?
thanks,
P
|
|
|
|
|
|
A side note, if you do anything affecting the shutdown sequence make sure to test it thoroughly. If you mess something up in XP (or prior) you can halt the standby/shutdown and drain the battery inadvertently. You also need to do whatever you're doing quickly. To avoid the hot laptop bag problem vista only gives apps a few seconds to wrap things up before going into standby even if an app hasn't OKed doing so.
|
|
|
|
|
You can still do what you want by putting a program in the startup folder that will verify the settings when the system reboots.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
when you press power button you will not have the power to detect anything
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Thank you for the help, i have been trying out the system events and it seems to fulfil my requirements
p
|
|
|
|
|
Hi,
My name is Sandeep and I am developing an application in C# .NET, which talks to a piece of hardware. This hardware is called Loop Tester and it is connected to series (loop) of fire detector, smoke detector, etc. I am informed by the Line manager that there is no need to study the hardware. What is needed at the initial stage is to develop a program which talks to piece of hardware, connected through RS232, which forms the communication base of the project. After successfully developing it, I can write the remaining application i.e. add functionalities. I am confused as to how i can start writing the program. I have gone through the article by Tapan Dantre and got some idea. Can anybody help me out?
|
|
|
|
|
You can use SerialPort class in net framework for communicating with devices that are connected to serial port.
|
|
|
|
|
Thanks for your quick reply.
I do have a general idea of how to use SerialPort component for communicating with the deveices that are connected to serial port, but my problem is how to initiate the hardware to perform some function and then read the output from the hardware (loop tester).
I have few lines of code written in VB6, which talk to the hardware with which fire detectors are connected in loop. This piece of code initiates the hardware to detect the numbers of devices in loop and then gives them all address (in hexadecimal).
If you have some time from your busy schedule and are willing to view the code, I am ready to send you the code and output screen shots so that you have an idea of what i want to write exactly in C#. Let me know if you are interested and forward me your email address so that i can mail you the code .
Thanks
|
|
|
|
|
I'm not sure what else to say, as RS232 is just a physical communication protocol, which is layer one of the OSI model. The format of the data sent and received is per device, as well as it would be you who needs to implement layer two though seven.
To help with layer two through four use a state machine in your back end wrapped around the .NET serial port class. It is good to be safe because serial communication can be prone to transmission errors that can soft lock your application.
|
|
|
|
|
Thanks for your quick reply.
I do have a general idea of how to use SerialPort component for communicating with the deveices that are connected to serial port, but my problem is how to initiate the hardware to perform some function and then read the output from the hardware (loop tester).
I have few lines of code written in VB6, which talk to the hardware with which fire detectors are connected in loop. This piece of code initiates the hardware to detect the numbers of devices in loop and then gives them all address (in hexadecimal).
If you have some time from your busy schedule and are willing to view the code, I am ready to send you the code and output screen shots so that you have an idea of what i want to write exactly in C#. Let me know if you are interested and forward me your email address so that i can mail you the code .
Thanks
|
|
|
|
|
Using the WMI code creator, which namespace, class and property do I select to get the printer connections in the system?
Thanks
|
|
|
|
|
"google" (that's what I would have to do to answer your question, and there's no sense in both of us doing it).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The reason for my question is that the printers I added to a remote machine using code, are added to the following registry settings in that remote machine.
The registry setting is:
HKEY_CURRENT_USER\PRINTERS\Connections\
I have searched google for WMI to return the data in the above registry path but have not found anything.
Any suggestions please?
Thanks
|
|
|
|
|
I have one textbox when user come to textbox, means Textbox_Enter then The Control Transfer (Focus) to Combobox and User Select Value From Combo and The value is Replaced in Textbox.
I am not Getting Focus to Combo.
Best Regards,
Chetan Patel
|
|
|
|
|
Both of these work for me.
private void textBox1_Enter(object sender, EventArgs e)
{
comboBox1.Focus();
}
textBox1.GotFocus += new EventHandler(textBox1_GotFocus);
void textBox1_GotFocus(object sender, EventArgs e)
{
comboBox1.Focus();
}
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)
|
|
|
|
|
i have problem in crystalreport.
error:Load report failed.
Vpost vpost = new Vpost();
int nopersoneli;
int.TryParse(vpost.txtNoPersoneli.Text.ToString(), out nopersoneli);
ReportDocument reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "@nopersoneli";
paramDiscreteValue.Value = nopersoneli;
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
crystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load("PostCrystalReport1.rpt"); reportDocument.SetDatabaseLogon("", "", "niloofar\\i2", "vezaratekar", false);
crystalReportViewer1.ReportSource = reportDocument;
|
|
|
|
|
Hello,
You might have tried these suggestions already but here is what I would check for the error "Load Report Failed".
1. If you are loading the report from a file be positive the filepath is correct.
2. ASPNET account needs access to the TEMP directory on the server.
3. Make sure to set the reportviewer's reportsource in page_init.
Also, you can handle the reportviewers error event and see if a different exception is available there.
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
is it possible to separate the windows installed fonts in separate listboxes or comboz based on its language? I mean list the arabic fonts in a listbox, english fonts on another box and one box for all?
|
|
|
|
|
Hi Guys. I have a strange thing happening. I have written an App that writes the current date to an Access Db as part of a record. I am forcing the format of the date to "ddMMyyyy" which works fine on my PC but when the users saves a record to the DB it saves the Date as yyyy/MM/dd even though I am forcing tyhe format to be "ddMMyyyy".
See below.
drNewRow["DateConf"] = DateTime.Today.ToString("ddMMyyyy");
Now, if I can't get this work properly I would like to convert the date when I export the data from the DB. Can anybody tell me how I can do this? Below the Export portion but I can't see how I can convert this date to be "ddMMyyyy".
sfw.WriteLine(dr["HolderRef"].ToString().TrimStart(mychar) +
dr["DateConf"].ToString() + dr["MobileNum"].ToString().PadRight(20) +
dr["EmailAdd"].ToString().PadRight(80) + dr["Comms"].ToString() +
dr["Confirmed"].ToString() + dr["Via"].ToString() +
dr["DateConf"].ToString());
Your help would be greatly appreciated.
Cheers
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Databases dont store the format of a date, they just store the date. When inserting a date, you should get used to using the ISO format which will negate any confusion about dd/mm/yyyy and mm/dd/yyyy. The iso format can be obtained by using
drNewRow["DateConf"] = DateTime.Today.ToString("yyyyMMdd");
As for formatting this date when you pull it out of the database, well you already know how to do that as you've just done it above.
... dr["DateConf"].ToString("ddMMyyyy")
|
|
|
|
|
Hi J. Reason why I send the date in format "ddMMyyyy" is that the Application that I eventually export the date to expects it to be in that format. When setting the format when I pull it out I get a compiller error of "No overloaded method 'ToString' takes 1 arguments.
Any other Ideas?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|