|
Hi all am working on a small project for work
part of the proccess is killing a proccess that is hung and i seem to be haveing trouble getting it to work
i think i could probably get a better understanding if i knew how to list all the running proccess on a machine at any given time.
does anyone know of an example that does this?
|
|
|
|
|
|
System.Diagnostics.Process[] aProcesses = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in aProcesses)
{
textBox2.Text = textBox2.Text + p.ToString() + System.Environment.NewLine;
}
|
|
|
|
|
Yep that should do it.
Ben
|
|
|
|
|
any elegiant suggestion on how to remove the extra text that is given in the loop
the system.diagnositc bla bla (firefox)
i want it to just show up as firefox
|
|
|
|
|
There are a lot of properties in the Process class.
So instead of p.ToString()
Perhaps you could just do:
p.ProcessName
Ben
|
|
|
|
|
|
I have a text file associated with my application.
Anyone can open and write on this file.
But I dont want anyone to write,delete or read this file.
How can i make my application do this?
Suggestion in both C# or VB.Net appreciated.
Thank You!
X
|
|
|
|
|
Well you'd have to set the permissions on the file to not allow access, but since your application will be running with the permissions of the logged on user then how would it access it if the logged on user cannot?
|
|
|
|
|
Dear originSH and other users,
When i am running the program, the program is only able to access the file. But if the program is not running, then the user shouldnot be able to open it, delete or write.
Can we write a program to do so?
I am in doubt whether this task is a programming task or some window operation.
Thank You!
X
|
|
|
|
|
You can do this, but it won't do you ANY good at all. There is nothing to stop the user from just giving himself the rights to the file again (outside of your app) and opening it in something like Notepad. You can NOT stop this from happening.
|
|
|
|
|
You can't keep people from messing with your file. You can look at encrypting the contence or something like that. So then at least they shouldn't be able to change it. Or if they did change it you would know since there would be an error when trying to decrypt the file. They could still delete the file though.
Ben
|
|
|
|
|
Hi,
I've spent last hour of my work trying to make String.LastIndexOf(string character, int startIndex, int count) work. I know that it's friday afternoon etc... but still, Am I overworked or is it really a bug ??
just try :
<br />
int GetLastPostion(string input, string character)<br />
{<br />
return input.LastIndexOf(character, 0, input.Length);<br />
}<br />
crashes, even
<br />
input.LastIndexOf(character, 0, input.Length - 1);<br />
<br />
input.LastIndexOf(character, 0, input.Length - 2);<br />
crashes.
wtf ???
|
|
|
|
|
It just crashes? .. or is it giving you an error?
|
|
|
|
|
ArgumentutOfRangeException:
Count must be positive and count must refer to a location within the string/array/collection.
Parameter name: count
|
|
|
|
|
Just one more question:
Is it this call that is actually crashing or is it possible that this is returning a -1 (because string is not found) to a function where -1 is out of range?
EDIT:
From MSDN:
ArgumentOutOfRangeException:
count or startIndex is negative.
-or-
startIndex minus count specify a position that is not within this instance.
|
|
|
|
|
This is correct. You are asking it to start searching from the start of the string, but the method works from the end of the string. It has nothing to search for.
|
|
|
|
|
I think you mean that reading this line, give you an exception :"CrossThread...."
if this what u mean, u need to invoke the thread :
if(textBox.InvokeRequired)
{
textBox.Invoke(method);
}
|
|
|
|
|
Hello all, hope this is the right board to post on.
I have a tab control on a c# pocket pc application. I am only using two tabs and so there is a plethora of empty space on the tab bar that I would like to utilize. I want to add a label over this space to use for program status updates; however, I cannot get a label control to appear above this area. I have tried to send the tab control to the back while bringing the label to the front, and I have even attempted to add the label to the tab control without success.
Any ideas on how I can accomplish this?
Thanks,
B
|
|
|
|
|
How to record a move of player? I am assuming in AddUser() if username entered is pc then PC image will be added and will start playing with human
I have following piece of code: Please help
int movenum;<br />
<br />
private int MoveNumber<br />
{<br />
get<br />
{<br />
return movenum; <br />
}<br />
set<br />
{<br />
movenum = value;<br />
}<br />
}<br />
<br />
<br />
public void AddUser(int user, string strText, string img)<br />
{<br />
lbls = new Label[] { label2, label4 };<br />
pics = new PictureBox[] { pictureBox1, pictureBox2 };<br />
<br />
user--;<br />
if (strText.Equals(""))<br />
{<br />
lbls[user].Text = "Guest";<br />
}<br />
else<br />
{<br />
lbls[user].Text = strText;<br />
}<br />
if (strText.Equals("pc"))<br />
{<br />
pics[user].SizeMode = PictureBoxSizeMode.StretchImage;<br />
pics[user].Load("C:\\WINDOWS\\system32\\setup.bmp");<br />
}<br />
else<br />
{<br />
pics[user].SizeMode = PictureBoxSizeMode.StretchImage;<br />
pics[user].Load(img);<br />
}<br />
<br />
userLoggedIn++;<br />
}<br />
private void switchPlayers()<br />
{<br />
if (player == 1)<br />
{<br />
player = 2;<br />
}<br />
else<br />
{<br />
player = 1;<br />
}<br />
<br />
checkAll();<br />
}<br />
<br />
private void box1_Click(object sender, EventArgs e)<br />
{<br />
if (userLoggedIn == 2)<br />
{<br />
box1.SizeMode = PictureBoxSizeMode.StretchImage;<br />
box1.Image = pics[player - 1].Image;<br />
box1.Enabled = false;<br />
switchPlayers(); <br />
}<br />
<br />
}<br />
<br />
private void box2_Click(object sender, EventArgs e)<br />
{<br />
if (userLoggedIn == 2)<br />
{<br />
box2.SizeMode = PictureBoxSizeMode.StretchImage;<br />
box2.Image = pics[player-1].Image;<br />
box2.Enabled = false;<br />
switchPlayers();<br />
}<br />
<br />
}<br />
<br />
private void box3_Click(object sender, EventArgs e)<br />
{<br />
if (userLoggedIn == 2)<br />
{<br />
box3.SizeMode = PictureBoxSizeMode.StretchImage;<br />
box3.Image = pics[player - 1].Image;<br />
box3.Enabled = false;<br />
switchPlayers();<br />
}<br />
<br />
}<br />
public bool CompareImages(Image image1,Image image2,Image image3)<br />
{<br />
if(!Object.Equals(image1,image2))<br />
{<br />
return false;<br />
}<br />
if(!Object.Equals(image2,image3))<br />
{<br />
return false;<br />
}<br />
if ((image1 == null) || (image2 == null) || (image3 == null))<br />
{<br />
return false;<br />
}<br />
return true;<br />
<br />
}<br />
<br />
public void checkAll()<br />
{<br />
if (CompareImages(box1.Image, box2.Image, box3.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box4.Image, box5.Image, box6.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box7.Image, box8.Image, box9.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box1.Image, box5.Image, box9.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box3.Image, box5.Image, box7.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box1.Image, box4.Image, box7.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box2.Image, box5.Image, box8.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (CompareImages(box3.Image, box6.Image, box9.Image))<br />
{<br />
DisplayWinner();<br />
<br />
}<br />
else if (box1.Image != null && box2.Image != null && box3.Image != null && box4.Image != null && box5.Image != null<br />
&& box6.Image != null && box7.Image != null && box8.Image != null && box9.Image != null)<br />
{<br />
lblDraw.Visible = true;<br />
lblDraw.Enabled = true;<br />
}<br />
<br />
}
|
|
|
|
|
Hi,
I am developing a windows application for the first time with visual studio C#.
When the user installs the application it must also install directories/files.
How can I add Directories with 'template' files(existing *txt, *.dwg files) to my application?
any suggestions?
greetzzz
|
|
|
|
|
When I click such column header where column contains both positive and negative values, the DataGridView makes sort only for the abs (no-negative) value. So the order is right only when column contains only positive numbers. DataGridView's datasource is DataTable where I have just added DataRows one by one. What should be done to get the sort right?
|
|
|
|
|
have you set the "value type" property of the column?
|
|
|
|
|
Thank you, that was exactly what was missing!
|
|
|
|
|
Hi all !
I need to develop a application where users will drag & drop user controls on the design layout (same like in www.formlogix.com, need to develop similar kind of application). And also if you look at "Ironspeed" (www.ironspeed.com), this application does a gr8 job with out creating a simple application from scratch. Please download trial version and look at it.
The layout will be similar to visual studio 2005, where we need to develop a toolbox, property box, solution explorer. And also i need to load user controls which was developed by another programmers. subsequently user will drag & drop controls from toolbox to a designer layout. Then i need to save that layout into a webpage.
There are certain limitation as i came to know.
1. Controls included as Textbox, Listbox, Dropdownlist, Label, Command button, Radio buttons, check boxes and User Controls (which we need to develop with certain functionality)
2. How can we able to incorporate winforms controls on a webpage, i know this cannot be done in this way either can we able to incorporate webcontrols into a winform application?
3. do we need to build user controls in winform application or in webapplication ?
4. This application intially thought to build in a web application through AJAX concepts but i could not able build architecture later we changed to win application taking a prototype as in www.ironspeed.com.
Guys, please help me building up the architecture as well as concepts to put in, appreciate your help and cooperation.
Regards,
krishna
|
|
|
|