|
You will need the DirectX SDK package, and some examples.
Search for DirectX on CodeProject !
Luc Pattyn
|
|
|
|
|
Hello,
I am developing a windows service in VS 2005 that will monitor time and do something every 5 seconds.
I have created some code using the stopwatch class. Can anyone tell me if this is the best way to do this .
<br />
protected override void OnStart(string[] args)<br />
{<br />
sw.Start();<br />
this.RunningTime();<br />
}<br />
<br />
protected override void OnStop()<br />
{<br />
sw.Stop();<br />
}<br />
<br />
private void RunningTime()<br />
{<br />
if (sw.IsRunning)<br />
{<br />
if (sw.Elapsed.Seconds == 5)<br />
{<br />
}<br />
}<br />
}<br />
Many thanks in advance,
Steve
|
|
|
|
|
In my opinion the best way would be to use one of the timer classes cause by using StopWatch you would end up with active waiting. As you're programming a service the System.Windows.forms.Timer component should not work as it relies on a message pump, but you can either use System.Timers.Timer or System.Threading.Timer class. Take a look at their documentation to get an idea on how to use them.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I am framing a sql statement like this select file_id,file_name from XCalibur_files where path Like 'c:\xalibur\*'(
C:\xcalibur\system\programs path exists in the table)
but it is returning zero results.
This is the code..
string AccessConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Xcalibur\System\Programs\XCalibur Database.mdb;Jet OLEDB:Database Password=170464PassFinn;";
//Create an OleDbConnection object,
//and then pass in the ConnectionString to the constructor.
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = AccessConn;
//Open the connection.
cn.Open();
string str1 = "select file_id,file_name from XCalibur_files where path Like '";
string str2= "c:\\xalibur\\"+ "*'";
//Use a variable to hold the SQL statement.
string selectString =str1+str2 ;
//Notice that this line passes in the SQL statement and the OleDbConnection object
OleDbCommand cmd = new OleDbCommand(selectString,cn);
//Send the CommandText to the connection, and then build an OleDbDataReader.
//Note: The OleDbDataReader is forward-only.
OleDbDataAdapter oledataadapter= new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
oledataadapter.Fill(ds);
MessageBox.Show(ds.Tables[0].Rows.Count.ToString());
Where i am doing wrong?
|
|
|
|
|
If I recall right the "*" character has no special meaning in a LIKE clause for Access or at least not the one it has in a shell. I think you have to use the "%" character if you want to match all path starting with "c:\\xalibur\\".
Furthermore you should use parameterized queries instead of building the queries by string concatenation as the latter is more error-prone and not safe against injection attacks. Take a look at the following article for more information: SQL Injection Attacks and Some Tips on How to Prevent Them[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
when i try to save a image to hard disk i got a Error ,Generic Error Ocurred GDI+
this is the code
img.save(path,imageformat);
please help
""""""""
|
|
|
|
|
This error is quite general, and ill descriptive. Could you please post more code of what you are trying to do exactly?
Regards
|
|
|
|
|
|
PS.
Your question -and code which is not surrounded bu pre tags- is a bit vague. I'm taking guesses here.
You don't need to call the event handler itself -though there are ways of doing it-. You can simply extract the code into a common method:
private void b1_Click()
{
MyMthod();
}
private void MyMethod()
{
}
Was that what you were looking for?
Regards
|
|
|
|
|
Maybe the Button.PerformClick method is what you're looking for.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi all
The following is the code for tree view child node text i am accesing the child node text from another Form2 but it doesnt works when i am running the applictaion the child node is created but the name doesnt appears
TreeNode childnode = new TreeNode(objform2.textBox1.Text);
root.Nodes.Add(childnode);
SAS
|
|
|
|
|
|
Hi
Urgent Please help.
I am creating word template project. I want to access the active document in this project.
Please help me to which instance I should us to access active document.
Thanks in advance
Amit
|
|
|
|
|
i have created a website but i am facing problem to create option "remember password on same computer"
if anyone have idea or code to use the same option please send me.
thank you!!!
contact me: ashish.0619@gmail.com
|
|
|
|
|
Ashish Porwal wrote: code of remember me!!!
System.out.print("remember me!!");
|
|
|
|
|
How to write the bussiness rules in triggers i want some examples
Hi all,
vikram929
|
|
|
|
|
Hello:
I'm having a bit of trouble understanding the use of passing a collection object (in my case an ArrayList) as a ref parameter to a method that needs to add to the collection or otherwise modify the ArrayList's contents. Basically, I'm wondering which is the better, or more accepted, way to do this.
Consider the following bit of code - Both of my Test methods will modify the contents of my ArrayList and allow me to access all the values in my Main() method. However, I don't really understand which would be the better way to do it. Could someone please provide me a bit of understanding on this particular use of ref? Maybe what the pros and cons are of the two ways I do it here... why would I pick one way over the other?
Thanks!
using System;
using System.Collections;
namespace TestConsoleApplication
{
internal class TCA
{
[STAThread]
private static void Main(string[] args)
{
try
{
ArrayList List = new ArrayList();
List.Add(1);
List.Add(2);
Console.WriteLine("Passing the array:");
Test(List);
foreach (int i in List)
{
Console.WriteLine(i);
}
Console.WriteLine("\nPassing the array as a ref parameter:");
Test(ref List);
foreach (int i in List)
{
Console.WriteLine(i);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
#region Pause
Console.WriteLine();
Console.WriteLine("Done.");
Console.ReadLine();
#endregion
}
private static void Test(ArrayList list)
{
list.Add(3);
list.Add(4);
}
private static void Test(ref ArrayList list)
{
list.Add(5);
list.Add(6);
}
}
}
|
|
|
|
|
Don't use ref unless you need it.
You only need the ref keyword if you want to change the actual variable that is used to call the method, not just the contents of the variable. Here is an example of when you would need the ref keyword:
private static void CreateList(ref ArrayList list) {
list = new ArrayList();
}
However, there is almost never any real need for the ref keyword. It's mostly used in procedural programming, seldom in object oriented programming.
The method that creates a list can be written like this, which will also make it clearer:
private static ArrayList CreateList() {
return new ArrayList();
}
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Thank you for making the use of ref more clear to me I appreciate it.
|
|
|
|
|
I want to upload some multimedia file to my website. Just like Youtube does. However, I searched google and didn't find any samples. It seems like there is a control called CSUpload Controls in .Net 2.0. But not sure whether it can load video file.
|
|
|
|
|
Hi
you mean upload any file,
I think uploading a video or any file doesnt matters,
So you can use FileStream class, you save copy any file on your server,
by also including the authancation mode.
Cheers.
|
|
|
|
|
Hi one & all
I m wirting a code for dynamic DataGrid, in that i have a column of Date. so store procedure is exactly working but in code some what mistake ,
I have written the code like this
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.DateTime");
myDataColumn.ColumnName = "CreatedOn";
myDataColumn.ReadOnly = false;
myDataTable.Columns.Add(myDataColumn);
In for loop, i have taken as
string noofre = Convert.ToString(dt.Rows[i]["CreatedOn"]);
myDataRow["CreatedOn"] = noofre;
myDataTable.Rows.Add(myDataRow);
But i m getting some problem to retrieve this.
So please kindly help me to solve this problem.
Regards,
Narendra
+91 9885179844.
Help this content to solve.
|
|
|
|
|
I'm trying to change some code found on the net so that it wil read and display the result in 9 texboxes.
The for statement works i just need to find out how use 'i' in stead of tbTargetAddress'0' so that for eatch 'i' I will use an other textsbox.
Example for the code is below...
In addition I would like to change the background color of the textbox depending from the 'if' result. I've found that set {tbResponseTime10.BackColor = Color[Red]} should do the trick but again a can't find the way to integrate this in the if statement.
Thanks,
Geert
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i<9;i ++)
{
MessageBox.Show(i.ToString());
try
{
TimeSpan span = ping.Send(tbTargetAddress0.Text, new TimeSpan(0, 0, 0,0,250));
if (span == TimeSpan.MaxValue)
tbResponseTime10.Text = "Timeout";
else
tbResponseTime10.Text = span.TotalMilliseconds.ToString("N1") + " ms";
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "Could not send ping command", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
|
|
|
|
|
new to this wrote: i just need to find out how use 'i' in stead of tbTargetAddress'0' so that for eatch 'i' I will use an other textsbox.
One easy way is to simply create an array of references:
TextBox[] tbTargetAddress = new TextBox[] { tbTargetAddress0, tbTargetAddress1, ... , tbTargetAddress8 };
Now you can access the textboxes using the array: tbTargetAddress[i].Text
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Hi,
For my programming purposes i've decided to implement a class called MyRectangle.
It has the x,y,width,height variables and some other important objects that i want contained into this MyRectangle object ... (I know of the system.Drawing.Rectangle, but that's not the point. I simply want to learn how to create own objects that can be drawn into a Windows Form)
I have now a Windows Form with a single button with the Click event; when button
clicked i want to draw my own object of MyRectangle. Simple enough just to test it.
Let's say i have a method drawMyRectangle() that perhaps uses the System.Drawing.Rectangle itself.
I've been reading about the Paint()-method, PaintEventArgs e and so on.. But i just can't connect it all..
Is there someone out there who can shine some ligth ?
Thanks from Daniel
|
|
|
|