|
System.Environment.UserName returns the Windows username of who started the thread that is calling that static property.
For the rest try to see MSDN for System.Diagnostics.Process and its members.
You can also access system infos using System.Diagnostics.PerformanceCounter that allows you to read information about cpu, ram, hdd usage, running processes, threads, modules and so on... That is a little complicated to use...
|
|
|
|
|
can ne1 plz tell me hw m goin to do this..
i hav a function in which i execute the datareader
ie--dataReader = SqlHelper.ExecuteReader(SQLConn,CommandType.StoredProcedure,"USP_GET_DATA" );
i declare getobj as array of objects..
after it gets all the data from the database in getobj ,
i want to fill the datagrid with the data...m not using dataset at all...m getting the values of each row in getobj
in the form_load
private void frmIATA_CODES_Load(object sender, System.EventArgs e)
{
NFDataObjects.IATACodeRequest [] getobj;
getobj=getIATA();
//here i want to write code to fill the datagrid with getobj which is array of objects
dataGrid1.//how to populate the datagrid???
}
ne help is appreciated....
|
|
|
|
|
Hi there friends,
I am working on a program that its language is not english(so mine!).
every time user wants to change the language he must press ALT+SHIFT
and this is annoying.How can I change language programatically?
Thank You!
|
|
|
|
|
Question: I would like to know if is there a method to send a mouse click to an application, more precisely to the apllication that stays behind my window.
Essentially I need to build a click-through window.
thanks to all.
|
|
|
|
|
Hello
I made a small software in C#. I want to add help feature in it. I dont know how to to do it Can any body give me an idea or help me in this regrad.
Regards
Asmyan
|
|
|
|
|
Install the "HTML Help Workshop" utility which comes with the Visual Studio. See the detailed help in this utility for creating HTML help (.chm file) for your program. Basic steps are as under:
1. Create a new Help project using the File-New command.
2. Add HTML files for the topics to be included.
3. Add / create Index and Contents file which will be used for the Contents / Index tabs in your help system.
4. Add graphics files etc. inside your html topic files.
5. Change properties of the help project file as per requirements.
6. Compile the help project to give you the .chm file.
Details on these individual topics can be seen in the HTML Help Workshop utility's help file which gives step-by-step details.
|
|
|
|
|
Excuse me, but where is located the HTML Help Workshop on the Visual Studio CDs? I tried with the standard installer but there is not. I searched on the CDs but I found only the HTML Help compiler, not the editor.
|
|
|
|
|
Have you guys ever realised that when you have a component class that has a timer, and when your Thread calling the method finishes off, the Timer events still gets fired.. Why is this so.. Look at the following code as an illustration.
public class WithTimer : System.ComponentModel.Component
{
private System.Timers.Timer timer1;
public WithTimer(){}
public void StartTimer()
{
int i=0;
while(true)
{
if(i==0)
timer1.Start();
i++;
}
}
}
public class MainApp
{
public static void Main()
{
WithTimer m_Timer = new WithTimer();
Thread _Thread1 = new Thread{new ThreadStart(m_Timer.StartTimer)};
_Thread1.background = true;
_Thread1.Start();
_Thread1.Abort();
}
}
Now as you can see in the code, after _Thread1.Abort(), i realise that m_timer events still gets called, even after the Thread has exited gracefully.
This ONLY happens with the Timer events. Anyone know why this is happening ?
Any solutions to this ?
Stanley
|
|
|
|
|
That's how Timers are supposed to behave, aren't they? They keep firing off events at regular intervals of time, until you call Stop.
By the way, why are you starting timers in a thread? Starting a timer is not going to take much time, you can do it in the main thread itself.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Reason being, I want to create a listener per thread.
Stanley
|
|
|
|
|
jbx1628 wrote:
Anyone know why this is happening ?
The Timer class creates a thread to run itself in. This obviously stays alive, but logically you would think if the thread that created it was aborted, it should abort any 'child' threads too. This doesnt seem to be the case though.
Now the solution should be:
override Dispose(bool disposing)
{
timer1.Dispose();
base.Dispose(disposing);
}
This should be called when the finalizer is called for the WithTimer either by calling Dispose() or letting it be GC'd.
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
Yeah, this is my curiosity as well. I taught any if the parent thread gets created, all it's child will get NUKED. Thanks for pointing this out...
Stanley
|
|
|
|
|
How can i capture the net send packts using C#.NET or in any other language. kindly help me.
Thnaks in advance.
Shahzad
|
|
|
|
|
you have to sniff TCP packets, but I don't know how to do this in C#. try searching on CodeProject: I think there is something useful
|
|
|
|
|
Hi,
I have made windows service program
In On start code i am calling exe file through process.start
inside on_start()function
Process.Start(@"c:\a.exe"); here i do not want to write complete path
I want to write only a.exe and path should be taken from my other project which i made another installation program for this project.
How can i retrive the path of a.exe so that my windows service automatcally retrive the path of location of a.exe
Client can install set up program of a.exe in any drive.
In that case how my windows service will retrive the complete path of a.exe
Pls suggest in this matter
This is very urgent
THanks and Regards
sanjeev
Everything is possible
|
|
|
|
|
Just write the path where a.exe is being installed to into the registry: Add a new registry key to your setup for a.exe and set its value to [TARGETDIR] .
Regards,
mav
|
|
|
|
|
Say i had a main class like..
class MainClass : Form
and i had another class
class Control
can I add a function to an event handler through the Control class to the mainclass? if not is there a way around this? any solutions will be appreciated thx for the help.
IM PROUD TO BE A GMAIL;
|
|
|
|
|
If I am reading you correctly, then the answer is yes.
((MainClass) this.ParentForm).MyEvent += new ...
|
|
|
|
|
Hi everybody.
Can somebody direct me to a correct algorithm to solve the sort problem of the following array of data:
ServerWeb.*
ServerWebSomething1
ServerWebSomething2
ServerWeb3
ApplicationServer1
App.*
ApplicationServer2
should be sorted as this:
ApplicationServer1
ApplicationServer2
App.*
ServerWebSomething1
ServerWebSomething2
ServerWeb3
ServerWeb.*
The point is that the data is first sorted alphabetically, and then withing the similar types of data I need to get the data with more specific to the top and those less specific to the bottom.
For instance, as ServerWeb.* covers all servers that starts with the "ServerWeb" it is the least distinctive, while ServerWebSomething1 is the most distinctive in that subgroup.
This just puzzles me, I would appreciate any algorithm in any language if C# example is not available.
Thanks.
|
|
|
|
|
What you need to do is to define a way to compare two of the values. If you just do that, you can then use any sorting algorithm. You can even make a class that implements ICompareable and use the SortedList class to sort them.
What information does the names contain? How do you separate the different parts of information? Why is, for an example, "ServerWebSomething1" more distinctive than "ServerWeb3"?
---
b { font-weight: normal; }
|
|
|
|
|
I am having some problems adding dynamic MenuItems to a context menu in a C# Windows application. Look at the pasted code below. Click the Add Item button a couple times, then right click anywhere in the checked list box. List Items should expand with a list of all the items in the checked list box.
Now, click the button a couple more times and notice the change on the right-click context menu. List Items no longer expands!
I've also tried:
Clearing ListItems.MenuItems collection and re-adding new MenuItems on Popup
A static list of MenuItems added to ListItems.MenuItems in InitializeComponent, set visible or not depending on the number of items in the check box
Any ideas?
Compile the code with: csc /target:winexe MenuTest.cs
////////////////////////////////////////////////
// Begin Pasted Code Here
///////////////////////////////////////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class MenuTest : System.Windows.Forms.Form
{
private System.Windows.Forms.Button AddItem;
private System.Windows.Forms.ContextMenu DynamicMenu;
private System.Windows.Forms.CheckedListBox ListBox;
private int ListItemCount = 0;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem ListItems;
private System.ComponentModel.Container components = null;
public MenuTest()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.ListBox = new System.Windows.Forms.CheckedListBox();
this.AddItem = new System.Windows.Forms.Button();
this.DynamicMenu = new System.Windows.Forms.ContextMenu();
this.ListItems = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
this.ListBox.Location = new System.Drawing.Point(8, 32);
this.ListBox.Name = "ListBox";
this.ListBox.Size = new System.Drawing.Size(120, 94);
this.ListBox.TabIndex = 0;
this.ListBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ListBox_MouseDown);
this.AddItem.Location = new System.Drawing.Point(32, 152);
this.AddItem.Name = "AddItem";
this.AddItem.TabIndex = 1;
this.AddItem.Text = "Add Item";
this.AddItem.Click += new System.EventHandler(this.AddItem_Click);
this.DynamicMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.ListItems});
this.DynamicMenu.Popup += new System.EventHandler(this.DynamicMenu_Popup);
this.ListItems.Index = 0;
this.ListItems.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3});
this.ListItems.Text = "List Items";
this.menuItem2.Index = 0;
this.menuItem2.Text = "Here Is A List";
this.menuItem3.Index = 1;
this.menuItem3.Text = "-";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(136, 189);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.AddItem,
this.ListBox});
this.Name = "MenuTest";
this.Text = "MenuTest";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new MenuTest());
}
private void AddItem_Click(object sender, System.EventArgs e)
{
this.ListItemCount++;
this.ListBox.Items.Add( "item" + ListItemCount.ToString() );
}
private void ListBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right )
{
System.Drawing.Point pt = new Point( e.X + 10 , e.Y + 25 );
this.DynamicMenu.Show( this, pt );
}
}
private void DynamicMenu_Popup(object sender, System.EventArgs e)
{
foreach( object o in this.ListBox.Items )
{
this.ListItems.MenuItems.Add( o.ToString() );
}
}
}
|
|
|
|
|
The problem is that you are not creating an instance of the menuitems. Use an ArrayList to store each new menu item. Also, it's best to add the menuitems in your method "AddItem_Click". So modify the AddItem_Click as follows:
<br />
ArrayList arr = new ArrayList(); <br />
private void AddItem_Click(object sender, System.EventArgs e)<br />
{<br />
this.ListItemCount++;<br />
this.ListBox.Items.Add( "item" + ListItemCount.ToString() );<br />
<br />
MenuItem mi = new MenuItem("item"+ListItemCount.ToString());<br />
arr.Add(mi);<br />
this.ListItems.MenuItems.Add(mi);<br />
}<br />
>/code>
|
|
|
|
|
I would like to send a string from one windows application to another.
Would anyone know how to do this using the SendMessage WinAPI function?
My attempts have failed so far.
|
|
|
|
|
Don't do it using the SendMessage method; that is for window messages.
Do you have access to the source code of both applications? If so, use .NET remoting or web services to pass a string.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Conversation With a Muslim
Judah Himango
|
|
|
|
|
Thank you for the response.
Yes I have the source code for both apps. At present, the apps are just for test purposes. Trying to determine the best method for application communication.
I've had a quick look at remoting. I was unable to figure out how a remoting object is able to communicate / attach itself to an application?
The information I am trying to send across is to inform an allow the application to perform some work.
|
|
|
|