|
I wasn't aware that i could put commands into the registry.
Could you show me how ot do it using the c:\Uninstall.exe as an example?
Thanks for your help
Kev
|
|
|
|
|
Colin pointed out the link to help. Here's the pertinent line:
The data value for a key is a command line.
Use a command line command, like "del", as in "del c:\uninstall.exe"
Remember good ol' DOS?
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Marc,
Thanks for clearing that up, that's the "Idiot Proof" answer i was after but...
When i create my key with the value of del c:\uninstaller.exe i just get a message saying Cannot find del... when i restart my PC.
I assume i am missing something very trivial and i'll probably kick myself when i get it sorted but can you tell me what i'm doing wrong. Does the registry entry's name have to be anything specific? oir is that irrelevant in this case?
Cheers
Kev
|
|
|
|
|
exhaulted wrote:
Cannot find del... when i restart my PC.
Ew. I had assumed that it would be able to run DOS commands. You might need to do something like c:\uninstaller /u, where you pass a command line parameter to itself. BTW, it won't crash if you tell it to delete itself--why would it? The running version is in memory. There is the potential, though, of a locking issue--a running app might have its file locked by the OS, but I'm not sure.
Strange stuff!
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Lol, after all that you are right, you can just tell it to delete itself!!
I just assumed there woudl be file locking issues but there's not.
Thanks to you all for your help.
Kev
|
|
|
|
|
exhaulted wrote:
How do i delete my uninstal.exe?
Check out: Win32 Q&A (MSJ 01/1996)[^]. It's an older article but I think it's an interesting approach (at least if you're not afraid of P/Invoking ). Now, I haven't checked out if you can use this technique in managed code, but if not you can at least create a helper executable to take care of the final deleting.
Best regards
Dennis
|
|
|
|
|
Thanks for your reply Dennis, i'm gonna see if i can get anything working with the registry entries first.
Cheers
Kev
|
|
|
|
|
I have a cosole application always running in background and checking if is it 10h5 or 11h15 now. If it is, the console app will print out a message. How can i do that
Thanks a lot!
|
|
|
|
|
use System.Timers.Timer
see here for example - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtimerstimerclasstopic.asp
|
|
|
|
|
Thanks a lot for your help
|
|
|
|
|
Look into the System.Threading namespace on msdn.
Simply create a thread and do something like
while (escape condition)
{
thread.Sleep(60000)
if (DateTime.Now.Minute == 15)
{
}
}
The thread.Sleep command simply stops the thread eating system resources by
making the thread wait for 60 seconds between checks.
Kev
|
|
|
|
|
Thanks! It really works
|
|
|
|
|
You're Welcome
Kev
|
|
|
|
|
|
Override the onDrawItem event:
protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
{
// Your menu drawing code
}
and set the OwnerDraw property of the menu items to "True"
--Aditya
|
|
|
|
|
Thanks for your help but there is no OwnerDraw property to the main form ( no this.OwnerDraw )and no OnDrawItem() to override from......
What have I missed ?
Udi
|
|
|
|
|
Hi,
I have a MDI form with a Main Menu item.
when i click a menuitem(say Create Child) i want to show a different form as the child form for the MDI form.
The following is the code which i have in the click event of the menu item.
private void mnuitmCreateChild_Click(object sender, System.EventArgs e)
{
Child frmChild=new Child(); // create an istance of the child from
frmChild.MdiParent=this; // make the MDI form as the parnet for the created child form
frmChild.Show(); // show the child form
}
When i click the menu item for the first item an instance of the form is created and shown as the child form. That is what i want.
But, my problem is when i click the menuitem(Create Child) one more time keeping the child created previously, one more instance of the same child is being created and shown as a different window.
How can i make sure that only one child is active all the time?
Thanks in advance.
|
|
|
|
|
Subrahmanyam_K wrote:
But, my problem is when i click the menuitem(Create Child) one more time keeping the child created previously, one more instance of the same child is being created and shown as a different window.
So, what you want is to make sure that only one instance of a particular child can be created?
The simplest way, and the best way with regards to feedback to the user, is to disable the menu item that creates that child, after it's been created. When the child is closed, re-enable the menu item. That way, the user gets some feedback when going to the menu that the child has already been created. The "Windows" menu item should show a list of all the child forms, BTW.
Otherwise, you'll probably have to maintain a collection of child forms and test to see if the child has already been created, and if so, bring it to focus. But you'll still need to handle the child's close event so that it can remove itself from the application's collection.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Thanks a lot for your suggestions.
That's a very good idea which provides some information to the user that the form has already opened.
Thank you once again.
Subrahmanyam.
|
|
|
|
|
well it makes a new instance because you type "Child frmChild = new Child();"
instead you want the singleton approach:
just add static instance attribute and static getInstance method -
<br />
class Child : Form {<br />
<br />
static Child instance=null;<br />
<br />
static Child getInstance() {<br />
if (instance==null) instance=new Child();<br />
return instance;<br />
}<br />
...the rest of the child class...<br />
}<br />
<br />
private void mnuitmCreateChild_Click(object sender, System.EventArgs e)<br />
{<br />
Child frmChild= Child.getInstance(); <br />
frmChild.MdiParent=this;
frmChild.Show();
}<br />
this way only one chlid form will form, and you can access it from everywhere in you program by using "Child.getInstance();"
if the constructor needs params then this complicates things but is still doable.
good luck,
Iftah.
|
|
|
|
|
Thanks a lot for the piece of code.
Subrahmanyam.
|
|
|
|
|
This is what I usually do: (actual code from an app I'm working on right now)
foreach(Form form in MdiChildren)
{
if(form is AttendanceForm)
{
if(form.WindowState == FormWindowState.Minimized)
form.WindowState = FormWindowState.Normal;
form.Activate();
return;
}
}
AttendanceForm af = new AttendanceForm();
af.MdiParent = this;
af.Visible = true;
I hope it helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I would like to find out how do I authenticate a user against a database in SQL 2000?
I am using VS 2003.
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
|
Hello,
I have created a C# application that calling the stored procudure in MS Access DB file.
Here's the sql for stored procedure called procs_BestMark:
"PARAMETERS startDate DateTime, endDate DateTime;
SELECT Max(Marks) AS Expr1
FROM Students
WHERE (((Students.ExamTime) Between [startDate] And [endDate]));"
Here's my code in C# to call the stored procedure after connected the MS Access DB successfully:
"
odbcnStudentStatus.Open();
odbCommand = new OleDbCommand("procs_BestMark", odbcnStudentStatus);
odbCommand.CommandType = CommandType.StoredProcedure ;
odbCommand.CommandText = "exec procs_BestMark ?, ?";
OleDbParameter paraSD = this.odbCommand.Parameters.Add("startDate",OleDbType.DBDate);
paraSD.Value = new DateTime(2000,1,1);
OleDbParameter paraED = this.odbCommand.Parameters.Add("endDate",OleDbType.DBDate);
paraED.Value = new DateTime(2006,1,1);
int max = (int)this.odbCommand.ExecuteScalar();
"
It throws an error: "oleDBException: Expected query name after EXECUTE."
What is that? I think I have assigned the name of the stored procedure successfully.
Please help!
Thanks
|
|
|
|