|
The code works for my computer's IP address but when I try an another IP address it gives the IP address of the target computer.
|
|
|
|
|
Here is the code
It works.
Thank you.
System.Net.Dns.GetHostByAddress(IPaddress).HostName.ToString();
|
|
|
|
|
But I have an another problem. I can't send ping every computers. Can you help me with it?
|
|
|
|
|
My.Computer.Network.Ping[^].
BTW, pinging a machine only tells you in the network stack of the target computer is working, up to a certain point, and that's only IF it doesn't have a firewall blocking ICMP traffic. It will NOT tell you if the target server you're trying to connect to is actually listening.
|
|
|
|
|
|
I want to update values of combobox in HTML pages by combobox in Windows Form by language C#
Thanks
|
|
|
|
|
how to clear this graphic? if i draw graphic to screen
example: public static void DrawToScreen(int pointX, int pointY)
{
IntPtr deskDC = UnmanagedMethods.GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(deskDC);
GraphicsContainer cont = g.BeginContainer();
g.SmoothingMode = SmoothingMode.AntiAlias;
g.SmoothingMode = SmoothingMode.HighQuality;
g.FillRectangle(new SolidBrush(Color.FromArgb(255, Color.Blue)), pointX, pointY, 2, 2);
g.EndContainer(cont);
g.Dispose();
UnmanagedMethods.ReleaseDC(deskDC);
}
this fucntion fill rectangle to screen.
if i need to clear screen(clear desktop), how i do?
please give some tips or hints for me
thanks a lot....
|
|
|
|
|
Why do you need to paint to the Desktop? Have you considered using a full-screen application instead?
|
|
|
|
|
Maybe it is a hoax.
Tan Li
I Love KongFu~
|
|
|
|
|
i can't using fullscreen
because i need to draw to screen when i drag mouse
now i can draw when drag but can't clear that screen
if draw on form, can use invalidate()
if not on form, how can i do?
please give some hints or tips to me
thanks a lot....
|
|
|
|
|
I'm really guessing now, but have you tried using Invalidate? It may force Windows to redraw the desktop (it is, after all, just a different kind of window). If not, I'm afraid I'm stumped, sorry.
|
|
|
|
|
how to use invalidate?
please advice me...
i read invalidaterect from dllimport user32.dll but don't understand
if have another function or other as same as invalidate.
please advice me.
thanks a lot...
|
|
|
|
|
hello
How not to hardcode conn string username/pwd in plaintext for log4net ADO.NET appender?
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="0" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<!-- How not to have username/pwd in plaintext? -->
<connectionString value="data source=LAPPC2;initial catalog=SomeDB;integrated security=false;persist security info=True;User ID=dev;Password=somepwd" />
...
</appender>
See above, username "dev" and password are in plaintext.
Same question for nhibernate - see example below:
<configuration>
<configSections>
<section
name="nhibernate_SomeDB"
type="System.Configuration.NameValueSectionHandler, System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
<section
name="nhibernate_AuditTrail"
type="System.Configuration.NameValueSectionHandler, System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate_SomeDB>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect" />
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
<add
key="hibernate.connection.connection_string"
value="Server=localhost;initial catalog=SomeDB;User Id=dev;Password=somepwd;Min Pool Size=2" />
</nhibernate_SomeDB>
<nhibernate_AuditTrail>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect" />
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
<add
key="hibernate.connection.connection_string"
value="Server=localhost;initial catalog=SomeOtherDB;User Id=dev;Password=somepwd;Min Pool Size=2" />
</nhibernate_AuditTrail>
</configuration>
dev
|
|
|
|
|
You can put the connection string in your app and set the connection string before attempting to use the database.
Or, you can encrypt it in the app.config file.
Google is your friend.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: You can put the connection string in your app and set the connection string before attempting to use the database.
That's how I do it with ADONET. But what about Hibernate and log4net? I can change connection strings on the fly/programmatically with log4net/nhibernate?
dev
|
|
|
|
|
I want to declare a simple array of stuct with the struct containing an array as shown below. But it does not compile. If you can't tell I'm very new to C#.
public struct ChangeRec
{
public datetime LastTimeStamp;
public int last ;
public int mode[10] ; // I want an integer array of values
}
if I change the last line as shown, it will compile, but how do I control the size and access the elements?
public int [] mode ;
This seems too simple to be this hard. Thanks
|
|
|
|
|
You declare an array with int[] and then you set it's size when you create it.
mode = new int[10]; This can go in your contructor.
If your array was of a class then they would all be null and would need to be newd individually, too. As they are int, they will all be fine, but I mention this for future reference.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Why does it have to be a struct? Unless this is for Interop I don't see the value in storing a reference type within a value type - why not just declare it as a class?
It definitely isn't definatley
|
|
|
|
|
moon_stick wrote: storing a reference type within a value type
What reference type?
only two letters away from being an asset
|
|
|
|
|
An array is a reference type, no? Of type System.Array??
It definitely isn't definatley
|
|
|
|
|
I guess I looked at the data type and ignored the array
only two letters away from being an asset
|
|
|
|
|
Personally, I'd make your struct a class, and use a generic list instead of an array.
At that point you could do something like this:
public class ChangeRec
{
private List<int> m_modes = new List<int>();
public DateTime LastTimeStamp { get; set; }
public int LastValue { get; set; }
public List<int> Modes { get { return m_modes; } }
public ChangeRec() {}
}
There is now no need to initialize the list beyond what's done in the class.
One other thing... I the variable "Last" refers to the last value added to the list. If that's the case, you can do this (uif you're using the code I posted above):
ChangeRec changeRec = new ChangeRec();
changeRec.Modes.Add(1);
changeRec.Modes.Add(2);
changeRec.Modes.Add(3);
changeRec.Modes.Add(4);
int lastValue = (int)(changeRec.Modes.Last());
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Monday, January 5, 2009 11:42 AM
|
|
|
|
|
i think the fixed keyword might help you
unsafe public struct ChangeRec
{
public DateTime LastTimeStamp;
public int last ;
public fixed int mode[10] ; // I want an integer array of values
}
}
The big problem here is that you'll have to allow unsafe code within your project so it's probably not the best plan unless you're planning to use interop.
i'd be tempted to implement the thing as a class and create getMode(int i) and setMode(int i) methods.
Russ
|
|
|
|
|
The reason is that C# does not allow us to have instance field initializer in struct.
there is a workaround if you do not want to use the unsafe code, such as:
struct MyStruct
{
public int last;
public int[] mode;
public int[] Mode
{
get
{
if (this.mode == null)
{
this.mode = new int[10];
}
return this.mode;
}
}
}
The code above can be compiled successfully.
Tan Li
I Love KongFu~
|
|
|
|
|
Like everyone else, I would question why this is not a class. That doesn't answer your question, however. If you do indeed need a struct...which indicates you need it to be allocated on the stack, I would do something like the following (this might not be exact...havn't used stackalloc in a long time):
public struct ChangeRec
{
public ChangeRec(byte modeSize)
{
mode = stackalloc int[modeSize];
}
public DateTime LastTimeStamp;
public int Last;
public int[] mode;
}
|
|
|
|