|
Hello everyone,
I need to develop a C# application which can read command inputs from a remote controller through a USB receiver, like the first picture on this link: http://twhtpc.com/index.php/hpremote
It does read certain commands such as the numpads, volume controls. However even I use override WndProc on NativeWindow, the application can't read some commands such as "My Music" and "My Videoes" these WM_INPUT.
Any help is deeply appreciated. Thank You in advance.
|
|
|
|
|
Hi,
The code below is a summary of what I have developed which returns 0 or 1 for intResult to indicate a success or failure.
How do I obtain the returned value from within the script when the script is executed?
I think this is to do with altaring the "Create" word in the code below.
Any thoughts please?
Thanks
System.Management.ManagementPath path = new System.Management.ManagementPath("Win32_Process");
object[] methodArgs = { "cscript.exe \\machinename\c$\scriptname.vbs", null, null, 0 };
intResult = (uint)processClass.InvokeMethod("Create", methodArgs);
|
|
|
|
|
The Win32_Process class doesn't return an Exit Code for a process. You'll hhave to use the .NET Process class to get an Exit Code, but, you'll have to get the process object before the script terminates on the target machine. Even then, I can't guarantee it's going to work to get the exit code.
|
|
|
|
|
Thanks but not sure how to get C# to do this.
|
|
|
|
|
|
Hi,
I have read it but does not seem to help me.
Let's say I have a simple vbscript called vbscript.vbs which has something like:
wscript.echo "hello"
In the c# code I would like to run this script and return the word "hello".
How do I do this please?
Thanks
modified on Monday, June 15, 2009 2:40 AM
|
|
|
|
|
Pleas I need help on this code.
onclick on the save button this problem will prevent it from carry out the operation.
on geting to myCommand.ExecuteNonQuery();
it give me this error below.
{"Must declare the scalar variable \"@Telephone_NoParam\"."}
pls help as I dont know what to do because am new to c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Kay_Nylon
{
public partial class COMPANY_INFO : Form
{
public COMPANY_INFO()
{
SqlConnection myConnection = new SqlConnection("user id=sa;" +
"password=admin123;server=ADEMOLAPC;" +
"Trusted_Connection=yes;" +
"database=Kay_Nylon_Db; " +
"connection timeout=30");
myConnection.Open();
//myConnection.Close();
InitializeComponent();
}
private void COMPANY_INFO_Load(object sender, EventArgs e)
{
}
private void btnSave_Click(object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection("user id=sa;" +
"password=admin123;server=ADEMOLAPC;" +
"Trusted_Connection=yes;" +
"database=Kay_Nylon_Db; " +
"connection timeout=30");
myConnection.Open();
//try
//{
SqlCommand myCommand = new SqlCommand("INSERT INTO Company_Info(Company_Id, Company_Name, Company_Address_Line1, Company_Address_Line2, Telephone_No, Fax, Email) " +
"Values(@Company_IdParam, @Company_NameParam, @Company_Address_Line1Param, @Company_Address_Line2Param, @Telephone_NoParam, @FaxParam, @EmailParam)", myConnection);
myCommand.Parameters.AddWithValue("@Company_IdParam", txtCompanyId.Text);
myCommand.Parameters.AddWithValue("@Company_NameParam", txtCompanyName.Text);
myCommand.Parameters.AddWithValue("@Company_Address_Line1Param", txtAddress1.Text);
myCommand.Parameters.AddWithValue("@Company_Address_Line2Param", txtAddress2.Text);
myCommand.Parameters.AddWithValue("@Telephone_NoParam", txtTelephoneNo.Text);
myCommand.Parameters.AddWithValue("@FaxParam", txtFax.Text);
myCommand.Parameters.AddWithValue("@EmailParam", txtEmail.Text);
myCommand.ExecuteNonQuery();
myConnection.Close();
// }
//catch (Exception sql)
// {
// Console.WriteLine(sql.ToString());
// }
}
}
}
|
|
|
|
|
please use <pre> and </pre> around your code to make it legible.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Well, what is the value of txtTelephoneNo.Text? If the value of a parameter is null, then it effectively doesn't get added. That said, I doubt the Text property of a textbox can ever be null, and I believe an empty string would be treated differently.
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: If the value of a parameter is null, then it effectively doesn't get added.
I don't think that's true.
|
|
|
|
|
I think so, unless I'm getting mad. SqlParameter has a value property, and if you want a sql null you set this to DBNull.Value, or the actual value if there is one. If null, then its like the parameter was never added.
It works well if you write a stored proc and default the value to null in Sql. You can just set the sql parameter to null in code, it doesn't get passed, and defaults to null Sql side.
Regards,
Rob Philpott.
|
|
|
|
|
It should either add the parameter or throw an Exception, not fail quietly.
I may want to set (change) the value later, and perhaps execute the statement multiple times.
|
|
|
|
|
Not at all. It's a simple means where you do not have to worry about null/DBNull conversion in code.
Regards,
Rob Philpott.
|
|
|
|
|
Hi Guys. I have written a Windows Service with a FileWatcher. Now, when there are new files in the directory it picks the files up fine but when it has to copy then out into a new directory I get an error of The given path's format is not supported . Below is the copy function.
try
{
string path = fsw.Path;
string outPath = "C:\\TestDir2\\";
char[] trimchars = new char[] { '.', 't', 'x', 't' };
DirectoryInfo dinfo = new DirectoryInfo(path);
foreach (FileInfo finfo in dinfo.GetFiles("*.*"))
{
File.Copy(finfo.FullName, outPath + finfo.FullName, true);
}
}
It stops on the line: FIle.Copy(finfo.FullName, outPath + finfo.FullName, true); . Anybody have any ideas?
Excellence is doing ordinary things extraordinarily well.
modified on Friday, June 12, 2009 8:26 AM
|
|
|
|
|
Did you debug to see what is the value in the variables and are they similar to what is expected as Copy params?
By the way what is the error? do you get an exception. If yes, which one?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Yes, I have debugged it and low and behold, I missed it, should not have used outPath + finfo.FullName , should have used outPath + finfo.Name .
Silly mistake.
Thanks anyway.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Help others by editing your original post add [solved] to the title and at the end anotate the solution.
There are those of flamable nature who might jump at a silly mistake, we all make them, so pre-empt them by telling them.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Happiness?? Never seen anybody else do that!!
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Thanks. Your original was, as I said, a bit of a silly mistake and in that scenario it is better to tell others that you have realised what you did wrong.
If everyone would mark the thread headers with the solutions the forums would be easier to follow.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I did that in my reply. I mentioned exactly what I did wrong and rectified it.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi,
I have the following code
StreamReader sr = new StreamReader(strMainPath);
string allRead = sr.ReadToEnd();
sr.Close();
regMatch = textBox1.Text;
if (Regex.IsMatch(allRead, regMatch))
{
richTextBox1.Find(regMatch);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectionBackColor = Color.Yellow;
}
from textBoxi.text i am getting the word to search.
It is searching and getting the result, if that word is there
it highlighed.But my problem is to focus on that text in text area.
If the file is very large ,i have to scroll to findout where is the highlighted text.Instead of that i want to focus on that text.
Is there any way?
Pls help
|
|
|
|
|
Hi,
have a look at ScrollToCaret().
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Damned you Luc!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Chill out you bloody Hungarian.
Did it really take you three minutes to type those two sentences?
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Yes it bloody did!
I had to do lots of copy/paste scroll test stuff. I don't just make these answer up off the cuff you know. Research is the answer. And Gin. Never underestimate Gin.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|