|
You need to use Process Class.
Below is the sample code which is used to open a notepad.
using System;
using System.Diagnostics;
class ProcessStartDemo
{
static void Main(string[] args)
{
Process pr = new Process();
pr.StartInfo.FileName = "notepad.exe";
pr.StartInfo.Arguments = "Sample.text";
pr.Start();
}
}
|
|
|
|
|
Hi, I'm trying to get the IP, subnet and gateway for my interfaces using IPInterfaceProperties but both UnicastAddresses and GatewayAddresses returns a collection...
How do I know which one to use?
Here is my loop and for now I'm just using UnicastAddresses[0] and GatewayAddresses[0] but that isn't always right
internal static NetworkAdapter[] AddExtraInformation(ArrayList adapters)
{
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkAdapter adapter in adapters)
{
foreach (NetworkInterface networkInterface in networkInterfaces)
{
if (!DescriptionToName(networkInterface.Description).Equals(adapter.DeviceName))
continue;
adapter.Name = networkInterface.Name;
adapter.OperationalStatus = networkInterface.OperationalStatus.ToString();
IPInterfaceProperties ipProperties = networkInterface.GetIPProperties();
if (ipProperties.UnicastAddresses != null)
if (ipProperties.UnicastAddresses.Count > 0)
{
adapter.Address = ipProperties.UnicastAddresses[0].Address.ToString();
adapter.SubnetMask = ipProperties.UnicastAddresses[0].IPv4Mask.ToString();
}
if (ipProperties.GatewayAddresses != null)
if (ipProperties.GatewayAddresses.Count > 0)
adapter.Gateway = ipProperties.GatewayAddresses[0].Address.ToString();
break;
}
}
return (NetworkAdapter[])adapters.ToArray(typeof(NetworkAdapter));
}
|
|
|
|
|
string hostName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostEntry(hostName);
foreach (IPAddress ip in ipEntry.AddressList)
{
//Please check ip values
}
For example, if you want to get IPv4 value, use "ip" variable which is using foreach statement;
if (ip.AddressFamily.Equals(System.Net.Sockets.AddressFamily.InterNetwork))
string result = ip.ToString();
Best Regard...
|
|
|
|
|
Thanks for your reply
I'm not sure how to tell which nic has the ip-number that I get from using your code.
Anyway, I changed my code to this, looping the addresses and checking for IsDnsEligible, that seems to do the trick or am I missing something?
foreach (UnicastIPAddressInformation address in ipProperties.UnicastAddresses)
{
if(address.IsDnsEligible)
{
adapter.Address = address.Address.ToString();
adapter.SubnetMask = address.IPv4Mask.ToString();
break;
}
}
|
|
|
|
|
hi,
i want dll to change the pitch of the sound in my Music player project..
can any one help me plz...
i googled it but m no dll is working properly in my program..
|
|
|
|
|
Hello,
i've got a custom UserControl (UserControl-Class with a panel in it) and now i want to let it interact as a container in the Designer. Well - on the web I found a lot of tutorials for this problem, but my problem is, that the designer doesn't put the Controls i add to my control to the panel. It put them into the UserControl itself.
So how can i tell the designer, that it should use "panel" as it's container and not the UserControl itself? I've tried different thinks like make a own class which extends "System.Windows.Form.Panel" and tell them, that it is the Container for the designer and puttet it into my UserControl but all those things doesn't work...
Thanks for your help
|
|
|
|
|
You should have searched on CodeProject.
Take a look at Designing Nested Controls[^] by Yours Truly.
Hope this helps!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I'm having alittle trouble with the SOCKS5 protocol. Maybe someone here can help.
http://www.rfc-editor.org/rfc/rfc1928.txt
the initial request consist of 3 bytes
request[0] = 0x05;
request[1] = 0x01;
request[2] = 0x00;
the response contains 2 bytes
response[0] == 0x05;
response[1] == 0x00;
the next request is 10 bytes
request[0] = 0x05;
request[1] = 0x03;
request[2] = 0x00;
request[3] = 0x01;
(destination IP).GetAddressBytes().CopyTo(request, 4);
int byte1 = (destination Port) / 256;
int byte2 = (destination Port) % 256;
request[8] = (byte)byte1;
request[9] = (byte)byte2;
now this is where im having trouble. with the next response. the first 4 bytes are fine
response[0] == 0x05;
response[1] == 0x00;
response[2] == 0x00;
response[3] == 0x01;
but with the next 4 bytes its supposed to return an IP address to which im supposed to send udp data to. the bound address, but it returns an ip of 0.0.0.0. then the next two bytes are fine which is the bound port to send the udp data to. now why would it be returning a null ip? am I just suppsoed to use the proxy IP when it comes to UDP?
modified on Sunday, October 11, 2009 4:11 AM
|
|
|
|
|
|
I working on application in which i need to log urls browsed in internet explorer. For this up till now i am using low level key hook to trigger application to copy address bar content i.e. user have to press 'c' to log the url.
But i need to automate this part such that when ever there is change in url at address bar, trigger is generated to copy it to log file.I need some pointer for this task.
language preference is c# as i need to integrate it in latter dev stage.
|
|
|
|
|
I'm trying to get my PropertyGrid to refresh when the control in the designer has finished resizing, i'm not exactly sure on how to do this. Is there a way to get it to update on a value change as i'd rather not have to pass a reference of the property grid to the control being resized in order to refresh the values.
I'm not sure if i explained that to well
|
|
|
|
|
Most controls hanve a OnResize event, if not you will need to search the event list and choose one. Either refresh the property grid in that event or have the property grid subscribe to the controls event.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
To clarify things. Is the PropertyGrid you talk about the one in the Visual Studio IDE, or one you have put on your form?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
How can I make it stop doing that?
I've been googling for hours, but they always say there is no solution.
Manually playing with GetFocus and SetFocus didn't even work, but it could be that I did something wrong there
|
|
|
|
|
This may sound like a silly question, but what is your tab order?
The lowest number control gets the focus on form load - I just tried it with a label, textbox, webbrowser and button, created in that order and the textbox got the focus as I expected.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Oh it's much worse than that, it doesn't even steal the "local focus" but it causes the entire window to steal focus (even though I disabled focus stealing with the TweakUI!)
|
|
|
|
|
Oo! Thats nasty!
Have you tried any of the webbrowser replacement controls?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Ah no, I couldn't find any
Are there any you would recommend?
|
|
|
|
|
I haven't tried any, but a quick google for "webbrowser control replacement" gave >1M hits. It's possible one of them might work. Good luck!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Most of them are just new wrappers around the old ActiveX control and thus have the same problem
|
|
|
|
|
Alright I'm just going to do it the hard way, HttpWebRequest s
|
|
|
|
|
I have started to make a basic generic list tree how ever when it comes to adding a parent that has more than one node I have realised that i need to some how dynamicly add loops to i can display the details from "n" number of nodes attached, of course this is a silly idea so i need some help on finding a more feasible solution, can any body help me?
This is my source :
class Program
{
static void Main(string[] args)
{
CsTree tree = new CsTree();
tree.AddNode(new CsNode<CsBox>(new CsBox(1,2,4,8)));
tree.NodeList[0].AddChild(new CsBox(100,200,400,800));
tree.NodeList[0].AddChild(new CsBox(2, 3, 4, 5));
tree.AddNode(new CsNode<CsBox>(new CsBox(1, 1, 1, 1)));
tree.NodeList[0].NodeMembersList[0].AddChild(new CsBox(2, 2, 2, 2));
tree.DisplayAllNodeData();
tree.NodeList[0].NodeMembersList[0].NodeMembersList[0].NodeData.DisplayDetails();
Console.ReadKey();
}
}
class CsNode<T>
{
public T NodeData;
public Dictionary<int, CsNode<T>> NodeMembersList = new Dictionary<int, CsNode<T>>();
public int NodeMemberCount = 0;
public CsNode(T nodeData)
{
NodeData = nodeData;
}
public void AddChild(T childData)
{
NodeMembersList.Add(NodeMemberCount, new CsNode<T>(childData));
NodeMemberCount++;
}
}
class CsTree
{
public Dictionary<int, CsNode<CsBox>> NodeList = new Dictionary<int, CsNode<CsBox>>();
public int TotalNodes = 0;
public void AddNode(CsNode<CsBox> node)
{
NodeList.Add(TotalNodes, node);
TotalNodes++;
}
public void DisplayAllNodeData()
{
for (int i = 0; i < TotalNodes;i++ )
{
NodeList[i].NodeData.DisplayDetails();
for (int k = 0; k < NodeList[i].NodeMemberCount; k++)
{
NodeList[i].NodeMembersList[k].NodeData.DisplayDetails();
}
}
}
}
class CsBox
{
public int X;
public int Y;
public int Width;
public int Height;
public CsBox(int x,int y,int width,int height)
{
X = x;
Y = y;
Width = width;
Height = height;
}
public void DisplayDetails()
{
Console.WriteLine("X {0} Y {1} Width {2} Height {3}",X,Y,Width,Height);
}
}
So far i have managed to get it to display the details of The Base node, and its child nodes attached, i want it so i can display an unknown number of nodes attached to the child nodes if any, ie Base- Child - node - node ect instead of just Base - Child
|
|
|
|
|
I presume there is a valid reason not to use a standard treeview or one of the many commercial controls. Infragistics does one with an outlookexpress style which combines a treeview and a listview. There is an excellent one here that is also opensource A Much Easier to Use ListView[^]
If you insist on rolling your own (not a bad thing) then you need to understan recursive structures, you need 2 methods. This assumes there is a heirarchical relationship in your collection.
LoadBaseNodes(Trreeview, Collection)
Create the top level of nodes into the treeview
Call LoadeSubNodes(ThisNode, Collection)
Add node to treeview
LoadeSubNodes(ThisNode, Collection)
Create the nodes that are children of ThisNode
Add nodes to ThisNode
Call LoadeSubNodes(ThisNode, Collection) <= this is recursive (calls itself)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for that i will see if i can implement it :P
I primarily wanted to make one to make a quad-tree for a mass collision simulation, so its not visual
|
|
|
|
|