|
Hi, how do you retrieve IP address and host name again?
|
|
|
|
|
ravfingcoder wrote:
how do you retrieve IP address and host name again?
Like you did the 1st time
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
that's how i did it my first time:
using System;
using System.Net;
namespace GetIPAddress
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
IPHostEntry hostInfo = Dns.GetHostByName("");
IPAddress myAddress = hostInfo.AddressList[0];
foreach(IPAddress address in hostInfo.AddressList)
{
Console.WriteLine("ipaddress: {0}", address.ToString());
}
}
}
}
u're welcomed.
norm
|
|
|
|
|
using System;
using System.Net;
class getip
{
public static void Main(string[] args)
{
IPHostEntry hostInfo = Dns.GetHostByName("host");
IPAddress myAddress = hostInfo.AddressList[0];
Console.WriteLine("ipaddress: {0}",myAddress.ToString());
}}
|
|
|
|
|
I am trying to figure out how to create a hidden column in the standard .net ListView control. The best I have come up with is to make the last column width 0, however that column is still resizable and the user can still see the resize handle when doing a mouse over. I want the column to be truly hidden from the user. Any ideas?
|
|
|
|
|
I'm not sure exactly what you're trying to do, but if you're trying to add some hidden data to a ListViewItem then I think you can just derive a new class from ListViewItem and add as many extra fields as you need of whatever type you need. They'd only be accessible from the code and the user would never know they're their. Is that what you're aiming for?
|
|
|
|
|
Wjousts wrote:
I'm not sure exactly what you're trying to do, but if you're trying to add some hidden data to a ListViewItem then I think you can just derive a new class from ListViewItem and add as many extra fields as you need of whatever type you need. They'd only be accessible from the code and the user would never know they're their. Is that what you're aiming for?
Yes that is sort of what I am trying to do Wjousts, however what I would want is a hidden data (member variable) available for every item in the list and I would want this data bound to the list item so that when an item is added, deleted or edited the corresponding hidden data follows suit. In Essence I would like something that behaved like a hidden column.
|
|
|
|
|
Hi
I want to send bitmap files from server to a client. Number of files is not defined... Can anyone suggest some good and efficient way to do it?
Currently I am doing this... but the problem is only first file is transfered. Any idea why?
<br />
TcpListener SERVER;<br />
TcpClient CLIENT;<br />
<br />
SERVER = new TcpListener(66);<br />
SERVER.Start();<br />
<br />
CLIENT = SERVER.AcceptTcpClient();<br />
<br />
System.IO.Stream STREAM = CLIENT.GetStream();<br />
<br />
Bitmap BMP = new Bitmap("J:\\test\\in\\1.jpg");<br />
BMP.BitmapImage.Save(STREAM,System.Drawing.Imaging.ImageFormat.Gif);<br />
STREAM.Flush();<br />
<br />
BMP = new Bitmap("J:\\test\\in\\2.jpg");<br />
BMP.BitmapImage.Save(STREAM,System.Drawing.Imaging.ImageFormat.Gif);<br />
STREAM.Flush();<br />
<br />
BMP = new Bitmap("J:\\test\\in\\3.jpg");<br />
BMP.BitmapImage.Save(STREAM,System.Drawing.Imaging.ImageFormat.Gif);<br />
STREAM.Flush();<br />
...............<br />
...............<br />
And on client end....
<br />
TcpClient c = new TcpClient("localhost",66);<br />
Bitmap b;<br />
<br />
try<br />
{<br />
int count = 0;<br />
<br />
while(true)<br />
{<br />
b = new Bitmap(c.GetStream());<br />
b.Save("J:\\test\\out\\" + count + ".gif");<br />
MessageBox.Show("One Saved");<br />
count++;<br />
}<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show("Out");<br />
}<br />
What I need it.... HELPPPPPPPPPPPP!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Oh my... it's hard to tell where to start. Since you start off with a comment about 'good and efficient', the first big issue is there is no reason to load those bits into a Bitmap object on both the server and the client just to do a file transfer. The short answer is, stop doing that and just transfer the bits directly.
Why it breaks the way it does is actually interesting. So here's the long answer for those interested.
Bitmap, like the rest of System.Drawing, is mostly a thin wrapper of the unmanaged GDI+ library. With that constructor you are eventually invoking the GdipCreateBitmapFromStream(IStream, GpBitmap*) API. The 'flat' GdiPlus functions aren't documented to my knowledge, but a the C++ wrappers around them are. (System.Drawing doesn't use those C++ wrappers, it calls the flat functions directly.)
If you have a look at the unmanaged GDI+ documentation for Bitmap::FromStream() you'll notice that the stream you are loading from must be seekable. The managed wrapper hides this. Unfortunately it doesn't hide it in a perfect way. If the stream is not seekable it slurps the _entire_ stream into memory and then calls GdipCreateBitmapFromStream on a seekable memory stream formed on those bits. This is a design bug in my opinion, and they should have just throw an exception when handed a non-seekable stream.
Oh, and the ALL CAPS VARIABLE NAMES have just got to go too, btw.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Thanks for your GREAT reply...
Blake Coverett wrote:
ALL CAPS VARIABLE NAMES
ha ha ha ha... I just used them here so that ppl can understand what they are... and I do not use them as routine.
And thanks for telling me interesting facts.
Okay... I should transfer the bytes... I should transfer the bytes... I should transfer the bytes... I should transfer the bytes...I should.... <remembering>...
Have Great and Productive Day;
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
i have added COM (xxclientx.dll) to my c# webproject.
as
using XMLProLib = XXCLIENTXLib;
& initialize as
public string GetGDSResponse(string GDSRequest)
{
XMLProLib.Client GDSClient = new XMLProLib.Client();
GDSClient.Host = "xmlpro.wspan.com";
GDSClient.Port = 8800;
etc......
}
most of times work & suddenly getting error as
System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure at GetGDSResponse(String GDSRequest)
it doesnt recover then need to restart computer ...
can you give me the solution for this.
please help me
thanks and regards
abhi
|
|
|
|
|
I wrote code :
namespace class1
{
public class class1
{
[DllImport("winmm.dll", EntryPoint="mciSendString")]
public static extern int mciSendString (
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
private void button1_Click(object sender, System.EventArgs e)
{
string s=new string(' ',10);
mciSendString("status "+"c:\\a.mp3"+" length",s,s.Length,0);
MessageBox.Show(s);
}
}
I want to get the music's length.I use code like above in vb and vb.net.I can get the music's length,but in C# i can't.In C#,if i get mcisendstring's return value,I can't get 0.How can i get the music length in C# use mcisendstring?Please me correct mistake!
|
|
|
|
|
you can try first open the file ,then send the string to get length:
StringBuilder sb=new StringBuilder(1000);
mciSendString("status MediaFile length " + path, sb, 10, IntPtr.Zero);
|
|
|
|
|
I am designing an app that will store data both locally and remotely (so it can be synchronized easily). I want to be sure that if a user choose to not let others view there data that it will be encrypted for extra privacy. My concern is the best way to go about this.
This is the way I had it thought out...but...:
When encrypting data for sending to remote server a random key is generated (based on time and/or other variables) first and stored in the local configuration file. Then when a machine wants to sync with the server it will download the data from server (still encrypted) and decrypt it locally using the key in the condif file.
The problem I have realized is that all the machines that are synchronizing using this system would have different keys.
What would be the best way to make sure all the comps are using the same key, whithout using something so obvious as username or password? Am I going about this all wrong? Ideas/Suggestions?
// Steve McLenithan
Family Guy: Season 2 - Episode 8
|
|
|
|
|
Umm.... ignoring the synchronization issue for a moment:
You want to store a generated key locally and use it to encrypt locally stored data but you don't want to require a password. How does this protect anything? In particular, what prevents the attacker from just running your program and seeing the private data?
Either you've left out some important parts of the story, or ROT13 is about all you should worry about for encryption.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Is anybody aware of any tutorials on codeproject (or elsewhere) that explains the basic of sending keypresses to applications.
For example, I want to create a small C# app that will send the keypress "5" to notepad every X amount of seconds.
|
|
|
|
|
Application.Sendkeys(), AFAIK.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hummmm...will the il code tell me how they implement sendwait? WaitForInputIdle(process) or ???
|
|
|
|
|
You could also hack up a PInvoke style "SendMessage" routine...I believe there are some articles regarding just that floating around here.
Jeremy Kimball
|
|
|
|
|
Hi,
How could i find a string in a string ?
For exemple, lets say i have the string "Hello! (How are you) ?", How could i find the string in the parentheses ?
Is there a function that would return the "How are you" ? If not, is there a way to find the position of the "(" and of the ")" ?
Thanks
Heel
|
|
|
|
|
Of the top of my head, if you are looking for a string that appears between brackets then this should work:
string myString = "Hello (how are you)?";<br />
int start = myString.IndexOf("(")+1;<br />
int end = myString.IndexOf(")");<br />
string subString = myString.Substring(start,end-start);<br />
subString will contain "how are you"
You might be able to do something with Regex as well, but I'm not real familar with that.
|
|
|
|
|
that's pretty straight forward string parsing. living hell? no.
|
|
|
|
|
hmm... have you heard of Regular Experession... do check them out.. they really can help you in finding patterns... while making Living Hell a 'bit' better place
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Hello,
I am trying to develope an SDI application that uses MDI to allow me to have lots of different types of child forms available, but only one is ever displayed.
Essentially my application has a common menu, toolbar and status bar. The parent window also has a tree control down the left side (like the folder view in Explorer). In the main body of this form I want to put an MDI child form, but disallow the Maximise, Minimise, etc. so that the child is always maximised inside the parent.
So far the best I've come up with for enforcing the rules I want are:
ChildA ca=new LessonA();<br />
ca.MaximizeBox=false;<br />
ca.MinimizeBox=false;<br />
ca.ControlBox=false;<br />
ca.WindowState=FormWindowState.Maximized;<br />
ca.MdiParent=this;<br />
ca.FormBorderStyle=FormBorderStyle.None;<br />
ca.Resize += new System.EventHandler(this.Child_Resize);<br />
ca.Show();
And the Child_Resize just sets the WindowState back to "Maximized".
However the problem with this is that the minimise and restore buttons exist and are clickable on the menu bar - The close button is also present, but not clickable. How do I get rid of these buttons?
Or does anyone have any other suggestions abount how to have lots of types of child forms sitting in the parent form and have it appear like they are a natural extension of the parent form and not a MDI-acting-as-SDI-Kludge?
One line of thought I have on an alternative is to have the children inherit from the parent form class - but I think that would cause more trouble than it is worth. I have a feeling the VS designer would get confused.
Any help is appreciated,
Colin.
|
|
|
|
|
I remember that in C++ it was no problem to use a pointer to a function to execute a function (or method), but is this doable in C#? What I'm thinking of doing is having an array of methods within a class and using a index to the array to select which function to execute. My next question would be what happens to my array of functions when I inherit from a base class, will I get the base class pointers or the derived class pointers?
Any thoughts?
|
|
|
|