|
Hi, I am working on a task scheduler. Apart from scheduling tasks, daily, weekly, etc .. I would also like to let them run at login, but more importantly before the system shuts down.
I tried several methods already:
(1) by trying to intercept the shutdown and starting the application. At the moment it works but sadly the writer of this example code mentioned himself that it's not that trustworthy. It doesn't always work. So that’s not the best solution.
private void PreventShutdown()
{
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
}
private void SystemEvents_SessionEnding(Object sender, SessionEndingEventArgs args)
{
if (args.Reason == SessionEndReasons.SystemShutdown)
{
args.Cancel = true;
}
}
(2) by using the group policy settings, and placing a script file (task.bat) in the "windows\system32\grouppolicy\machines\scripts\schutdown" folder + a scripts.ini in the ... scripts folder. (apparently you can't access these GP, scripts settings programmatically)
If you do this manually (gpedit.msc) it works, but if you generate the files in code and place them in the appropriate folders it doesn't.
Can anyone help me with this problem. Is there anyone that has some experience with this, knows other ways to achieve my goal or maybe tell me what I'm doing wrong ?
Any help/suggestions much appreciated.
Thanx
modified on Sunday, March 8, 2009 8:57 PM
|
|
|
|
|
after some more googlin and reading thru msdn, I found the settings of the group policy scripts in the registry.
So I tried it like that; creating the right keys and values in code.
the tasks pop up in gpedit, scripts, shutdown ...
Every setting looks the same as when I would do it manualy with gpedit. Still when I shutdown the system, no batch file is being run. (the batch file itself works fine)
Is there nobody on this forum that has some experiance with this kinda stuff ?
thanx
|
|
|
|
|
Hello
I'm trying tu use mouse event (move, click) to select elements on a page on a printpreview control
But HOW can I get the page location relative to the princontrol Bound ?
Thank you very much for any help
|
|
|
|
|
hi
i used a Microsoft.Office.Interop.Owc11.ChartSpace object
it works and draw me a nice chart but when i use following code
if (ChartSpace.Charts.Count != 0)
ChartSpace.ExportPicture("C:\\abc.jpg", "Jpg", 640, 400);
it will be rise an exception "Unknown error."
with error code : -2147467259
what would i do?
thanks in advance.
|
|
|
|
|
i have com component which i converted to dll using tblimp tool. I am able to add reference of the dll to my code but when i call the function of the dll i get an error message saying "cannot find entry point"
could any one help me out in solving these issues.
|
|
|
|
|
It is very important to me to convert the webpage to images
pls help me out
I shall be grateful to you
|
|
|
|
|
http://www.codeproject.com/KB/graphics/IECapture.aspx[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
how it can be encrypted..............
if you can't put it here pls mail me
@ vinod8812@gmai.com
|
|
|
|
|
Hi all,
i just download a itextsharp.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using _____.itextsharp; <-- What should i put at this line ?
For PDF Converter & Image Converter
Thank you
modified on Sunday, March 8, 2009 4:11 AM
|
|
|
|
|
|
How do I invoke external windows applications (AutoCAD) through C#.Net code?
Zaki
|
|
|
|
|
|
My english is poor,so if i misunderstood your question please do not make fun of me.
System.Diagnostics.Process.Start(String filePath);
the parameter filePath you can read form the regedit;
|
|
|
|
|
How do cut data from datagrideview ?
|
|
|
|
|
to cut data from gridview
there are two ways:
1. cut datafrom grid source
2.cut the grid rows or columns
we can delete rows or columns by this way
//gridview1.Deleterow(indindex)
//gridview1.col
for more pls inform me
|
|
|
|
|
Hey all,
I hope someone can point me in the right direction, if im in the wrong place please let me know - didn't want to post in the WCF forum as this is still the old version 2.0 remoting.
I have created a remoting object - although it still looks really limited - however i still don't get the 'why' of remoting.
In this case i thought that remoting would be the correct way to get my service to communicate with a UI.
I have written a UI, it starts up as a separate client (with lets call it UIConsoleInterface), and instantiates a object (lets call it UIConsole) in the server menory/process/etc space.
The issue i have must be simple as no one actaully talks about the bit that is confusing me.
When the object is created in the server (UIConsole)it is created as a singleton - but it is started on demand from the client. This means that i can't initialise variables etc in the object as my application has no idea that is has been created (right?)
The issue is that the UI is state dependent - it needs to know what is going on in the service, all examples i've seen just work with data created during the constructor of the remotable object.
The only way round this that i can see is to create a static object that my UIConsole object can call to get data from the application - this seems really very messy.
I also have tried to create a local UIConsole object during the server startup - this involves activators and unwrapping the object - but even then when my client connects it creates a second instance of UIConsole.
So first question - What's the best way to get a service to communicate (2-way) with a UI
Second question - what is the official/best practices way to tie a remotable object to local data on your server?
Or should i just get over it and use the static object as my bridge between the service data and the local remotable object?
Any help appreciated!
|
|
|
|
|
Hi,
trying to help with my limited experience (a 1 time use of remoting which was great for me)
I've stopped at this line in your question,
I also have tried to create a local UIConsole object during the server startup - this involves activators and unwrapping the object - but even then when my client connects it creates a second instance of UIConsole.
in my application I've used remoting for a 2nd instance of my application to communicate with the first and only one,
make your server rerun the client with parameters (parameters== the data you want to send to the client),
make an if to check if there is an instance already running (you can find a lot of examples to that on google and in this site),
if its not the first time, instead of running for the 2nd time, use remoting to send the parameters to the first instance,
(if you need help with that part i can help), and quit the 2nd instance
hope this helps in something
|
|
|
|
|
In C# fore color of datimepicker have default color black.
Now, I want to change fore color :Black->blue
Do i do?
Thanks
|
|
|
|
|
Unfortunately this is not possible. MS have hardcoded it to use either SystemColors.ControlText or Colors.Black (I'm not sure which).
The ForeColor property is hidden as any change to it is ignored.
You can 'roll your own' by deriving from DateTimePicker . In the constructor call
Style(ControlStyles.UserPaint, true); then override OnPaint and draw it yourself.
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 don't normally give 'full' code but I've had a play around to make sure the advice I gave earlier was correct, so I figured I may as well share.
This enables use of the BackColor as well as ForeColor. I've used the DropDownButton part of the ComboBox for ease. I haven't implemented any of the editing on the text part of the control that is available in the .Net supplied one as that isn't quite as trivial! I also haven't checked the Enabled state to alter the way it's drawn, and I haven't drawn any border around the control as I can't remember how to get the colors in use by the system.
So there's plenty left to do but it should give you a start.
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace MyControls
{
public class MyDateTimePicker : DateTimePicker
{
public MyDateTimePicker()
: base()
{
this.SetStyle(ControlStyles.UserPaint, true);
}
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
DefaultValue(typeof(Color), "Window")]
public override Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = value; }
}
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
DefaultValue(typeof(Color), "WindowText")]
public override Color ForeColor
{
get { return base.ForeColor; }
set { base.ForeColor = value; }
}
protected override void OnPaint(PaintEventArgs e)
{
StringFormat stringFormat = new StringFormat();
stringFormat.LineAlignment = StringAlignment.Center;
using (Brush brush = new SolidBrush(BackColor))
{
e.Graphics.FillRectangle(brush, 0, 0, ClientRectangle.Width, ClientRectangle.Height);
}
using (Brush brush = new SolidBrush(ForeColor))
{
e.Graphics.DrawString(Text, Font, brush, ClientRectangle, stringFormat);
}
Rectangle dropDownRectangle = new Rectangle(
ClientRectangle.Width - Height, 0, Height, Height);
if (ComboBoxRenderer.IsSupported)
ComboBoxRenderer.DrawDropDownButton(e.Graphics, dropDownRectangle, ComboBoxState.Normal);
else
ControlPaint.DrawComboButton(e.Graphics, dropDownRectangle, ButtonState.Normal);
}
}
}
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)
|
|
|
|
|
hello sir/mam
i have a problem plz solve me out this problem.
i am working on a window application in c# .i have a datagrid which contain a DataGridBoolColumn and datagridtextboxcolumn.i am using table name as stock which contains feild subject,bookname,rate,sellrate,quantity.lbltotal is the label which shows the the total of sellrate.now my problem is that i have to show only those total which are checked
means if any one unchecked the check box the sellrate must be deducted in the from the total.
and i have to insert all the rows of the datagrid in the table except those which are uncheked.plz help me . thanks in advance
try
{
SqlConnection cn=new SqlConnection(Class1.connect());
SqlDataAdapter cmd=new SqlDataAdapter("select subject , bookname,rate,sellrate ,quantity from stock where class ='"+txtclass.Text+"'",cn);
// DataSet dt=new DataSet();
DataTable dt=new DataTable("stock");
cmd.Fill(dt);
dataGrid1.DataSource=dt;
this.dataGrid1.TableStyles.Clear();
DataGridTableStyle tb=new DataGridTableStyle();
tb.MappingName="stock";
DataGridBoolColumn td=new DataGridBoolColumn();
td.MappingName="rate";
td.HeaderText="";
td.AllowNull=true;
td.Width=20;
tb.GridColumnStyles.Add(td);
DataGridTextBoxColumn txt=new DataGridTextBoxColumn();
txt.MappingName="Subject";
txt.HeaderText="Subjects";
txt.Width=160;txt.ReadOnly=true;
tb.GridColumnStyles.Add(txt);
txt=new DataGridTextBoxColumn();
txt.MappingName="bookname";
txt.HeaderText="Book Name";
txt.Width=200;
txt.ReadOnly=true;
tb.GridColumnStyles.Add(txt);
txt=new DataGridTextBoxColumn();
txt.MappingName="sellrate";
txt.HeaderText="Rate";
txt.Width=160;
txt.ReadOnly=true;
tb.GridColumnStyles.Add(txt);
dataGrid1.TableStyles.Add(tb);
// SqlConnection cn=new SqlConnection(Class1.connect());
SqlCommand cd=new SqlCommand("select sum(sellrate) from stock where class='"+txtclass.Text+"'",cn);
cn.Open();
SqlDataReader dr=cd.ExecuteReader();
if(dr.Read())
{
lbltotal.Text="Total = "+dr[0].ToString();
}
else
{
lbltotal.Text="Total = 0 0";
}
cn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,Class1.name());
lbltotal.Text="Total = 0 0";
}
|
|
|
|
|
well, you should you make a function 'UpdateTotal' and call it on that column value change event.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I do not really understand what your mean,
I suggest if you can like this:
td.TrueValueChanged += new EventHandler(td_TrueValueChanged);
|
|
|
|
|
Send receive files over bluetooth, discover bluetooth devices using franson bluetools on Pocket PC (Windows Mobile)
modified on Saturday, March 7, 2009 3:39 PM
|
|
|
|
|
There's samples etc on the vendor's site[^] and a reference manual[^]. All that from the first result in Google[^].
Please search in future before asking here - especially when it comes to 3rd party tools!
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)
|
|
|
|