|
The line takes the reference to Form1 and stores it in the private variable.
"this.mainForm" refers to the private variable in the Form2 class. "mainForm" refers to the parameter that you send to the constructor.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you very much for the assistance. I have it working now! -mutty
|
|
|
|
|
Hi, all,
I use below command to get X drive to be mapped. I get the drive but it is not actived. I need to double click on it to make it active. Is it possible to make it active in the programs.
string strCmdLine;
strCmdLine = "/C net use X: \\\\locla01\\d$ \"******\" /user:coby";
System.Diagnostics.Process.Start("CMD.exe",strCmdLine);
I appreciate your help.
Thanks.
coby
coby
|
|
|
|
|
Hello everybody
Can you please tell me how can i start the explorer search engine from within a c# program... say.. when i press a button...just as if i would press
start\search\For Files or Folders...
please help me... thx
|
|
|
|
|
|
Hope this helps... thank you.
|
|
|
|
|
Hi,
Is there a way to make NumericUpDown controls unlimited in the number that's allowed to be entered? I think the default maximum is 100.
Thanks,
Yigal
|
|
|
|
|
Unlimited is not possible, how could a computer store unlimited numbers?
The NumericUpDown uses the "decimal" datatype, which has a maximum value of 79228162514264337593543950335.
Set the Maximum property of the NumericUpDown control to the value you want to use.
|
|
|
|
|
Hello all,
I have an XML schema that has been converted to a class file using the Framework XSD tool, this schema has default values specified within it and these have been carried across into the schema class. If I read in an XML file and then deserialise it to an object if any of the elements are not present the default value is picked up and the object uses that instead.
All it good, code works fine, I have happy little imps running around inside my head.
but......
For logging purposes I would like to know when this happens, ie. when the deserialiser uses the class based default value. The only solution I can think of is to parse through either the text XML or the desrialised object, which is an for to much additional processing for my liking.
Parsing the object values also present the problem that the XML file may actually contain the default value so you wouldnt know if it came from the XML file or the class defaults.
On a similar subject, XSD generate default values using the following header:
[System.ComponentModel.DefaultValueAttribute("localhost")]
public string blah = "localhost";
Is there any way in code I can access the DefaultValueAttribute??
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
hi.
I new to C# and would like to know how i send an ARP packet to a computer using sendarp from iphlpapi.dll.
I saw this code somewhere on the web, and its what i need. but i have little idea how to use it:
[DllImport("iphlpapi.dll", ExactSpelling = true)]
public static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);
I can see that a function is being build.
Can i just use it by doing this:
Int32 IP = Convert.ToDecimal(192.168.0.1);
SendARP(IP,0,0,IP.Length)
or how do i do it ?
|
|
|
|
|
Mmm, no, that won't work.. You can't create integer IP's from just using Convert.ToDecimal(). That would be too simple.
Also, you can't pass in a 0 for the 3rd parameter, it's a byte[] that's returned out as your data that you receive from the ARP I think (I haven't done any research, I'm just letting you know basic things that are wrong.)
What this all means is that you need to:
a) Declare a byte[] to use for the 3rd parameter. I'd reccomend using one that's got a decent length, like 256...declared as so: byte[] buffer = new byte[256]; (Note: You might not even need to declare a length, since you have that ref integer parameter that seems to tell you how much data you got out of the function - I'd try both ways)
b) for the 4th parameter, you need to declare an integer before calling the function, then pass that integer in as a ref parameter...that variable will hold the length of the actual output from the function (how much data it filled in the buffer)
c) you need IP's as integers...fortunately for you, I've written code that does that.
public static int StringIPToInt(string IPString)
{
string[] _splitString = IPString.Split(new char[]{'.'});
int _retVal = 0;
if (_splitString.Length < 4)
throw new ArgumentException("Please pass in a valid IP in dotted-quad notation!","IPString");
else
{
_retVal += (int)(int.Parse(_splitString[3]) * Math.Pow(256,0));
_retVal += (int)(int.Parse(_splitString[2]) * Math.Pow(256,1));
_retVal += (int)(int.Parse(_splitString[1]) * Math.Pow(256,2));
_retVal += (int)(int.Parse(_splitString[0]) * Math.Pow(256,3));
}
_retVal = (int) (((_retVal & 0x000000ff) << 24) +
((_retVal & 0x0000ff00) << 8) +
((_retVal & 0x00ff0000) >> 8) +
((_retVal & 0xff000000) >> 24));
return _retVal;
}
I won't go into detail except that all the compound addition you see is parsing the dotted-quad notation and creating an integer value to represent it (dotted-quad just stores the 32 bits of an IP address as four octets, so it's easy to go back to a 32bit integer). The last bit of code with all the bitshifting and binary AND's flips the endianness of the output integer so that you have the correct value.
So, a call like this may be appropriate:
byte[] outputData;
int dataLength = 0;
SendARP(StringIPToLong("192.168.1.101"),StringIPToLong("127.0.0.1"),outputData,ref dataLength);
I would then use BitConverter.ToString() or something similar to get human-readable data out of that buffer byte[].
|
|
|
|
|
Thanks for the fast reply.
I think i have figured the SendARP() out now, but i still can't give it the IP destination in integer.
i tried with the code you provieded me, like this:
<br />
public partial class _Default : System.Web.UI.Page <br />
{<br />
[DllImport("iphlpapi.dll", ExactSpelling = true)]<br />
public static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
byte[] outputData = new byte[6];<br />
int dataLength = outputData.Length;<br />
SendARP(StringIPToLong("192.168.1.101"), StringIPToLong("127.0.0.1"), outputData, ref dataLength);<br />
Label1.Text = "MAC:" + BitConverter.ToString(outputData, 0, 6);<br />
}<br />
<br />
public static int StringIPToInt(string IPString)<br />
{<br />
string[] _splitString = IPString.Split(new char[] { '.' });<br />
int _retVal = 0;<br />
if (_splitString.Length < 4)<br />
throw new ArgumentException("Please pass in a valid IP in dotted-quad notation!", "IPString");<br />
else<br />
{<br />
_retVal += (int)(int.Parse(_splitString[3]) * Math.Pow(256, 0));<br />
_retVal += (int)(int.Parse(_splitString[2]) * Math.Pow(256, 1));<br />
_retVal += (int)(int.Parse(_splitString[1]) * Math.Pow(256, 2));<br />
_retVal += (int)(int.Parse(_splitString[0]) * Math.Pow(256, 3));<br />
}<br />
_retVal = (int)(((_retVal & 0x000000ff) << 24) +<br />
((_retVal & 0x0000ff00) << 8) +<br />
((_retVal & 0x00ff0000) >> 8) +<br />
((_retVal & 0xff000000) >> 24));<br />
return _retVal;<br />
}<br />
The error i get is:
Default.aspx.cs(24): error CS0103: The name
'StringIPToLong' does not exist in the current context
That sound like it can't find the StingIPToLong function in the current codeblock, but the function is declared "public" so i thought that it worked in all codeblocks.
|
|
|
|
|
GentooBoxX wrote:
That sound like it can't find the StingIPToLong function in the current codeblock, but the function is declared "public"
Look at your code. You renamed the function to "StingIPToInt" but are calling "StringIPToLong"
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Thanks
Typical newbie error.
|
|
|
|
|
I actually renamed the function when I was typing the comment (so as to simplify for you - I represented an IP as a long variable instead of an int in my app).
Did it help you with what you needed?
|
|
|
|
|
|
i have a form on which i have drawn some text using drawString(...) method. now i want to zoon that text. how can i do that??????
|
|
|
|
|
Zooming? Wouldn't it be better if you specified a different font size when you draw it?
---
b { font-weight: normal; }
|
|
|
|
|
Hello everybody.
I want to transfer my software to another computer which doesn't install the visual studio.net. I tried to copy the .exe file to the target machine, obviously it doesn't work. Is there any installer or setup package to achieve this in C#???
Could anybody help me with this please??
Thanks in advance
Asura
|
|
|
|
|
Your customers need to have the .NET Runtime 1.1 installed.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Is the runtime 1.1 in the installation disk of Visual .net???
Can I just copy the libraries I need to the target computer???
Thanks
Asura
|
|
|
|
|
This is what your clients need.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
i have written an asynchronous server. when one client connects to the server there is no problem. the problem appears when more than one client tries to connect to the server on the same computer. the exception seems to be raised when i bind the server to a certain ip and then start listening to a spesific port:
obj_Socket.Bind(ListenEP);
obj_Socket.Listen(11000);
|
|
|
|
|
|
A port can be bound only once, you're probably trying to bind it more than once (every time a client connects?) .
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|