|
I think you might want to check out using Active Directory to retrieve info like that. Try this article[^] for example.
Josh
|
|
|
|
|
I think what Josh said is good advice.
There is another way to attack the problem, if you're interested. You could send out ARP (Address Resolution Protocol) requests to IPs on the whole network and see what responses you get. An ARP request is broadcasted to the whole network and it basically asks the question: "Who has IP address www.xxx.yyyy.zzz?". Each device on the network looks for such packets and will reply to the sender with its MAC address, which then allows the sender to associate an IP Address with a MAC address so that it knows how to get packets to that device.
For example, let us say that you are on a computer whose IP address on the LAN is 192.168.2.33. You want to know what other computers are out there, specifically on the subnet 192.168.2.x. Let us further say that there are three more machines on that subnet: 192.168.2.50, 192.168.2.67, and 192.168.2.4. Your computer sends out a whole slew of ARP requests, like this (this is what it might look like in a packet sniffer):
From: 192.168.2.33 BROADCAST --> who has 192.168.2.1 ?
From: 192.168.2.33 BROADCAST --> who has 192.168.2.2 ?
From: 192.168.2.33 BROADCAST --> who has 192.168.2.3 ?
From: 192.168.2.33 BROADCAST --> who has 192.168.2.4 ?
....
From: 192.168.2.33 BROADCAST --> who has 192.168.2.255 ? Now when those three machines see their addresses asked for, they reply to your computer like so:
From: 192.168.2.50, To: 192.168.2.33 --> 192.168.2.50 is at [some MAC Address]
From: 192.168.2.67, To: 192.168.2.33 --> 192.168.2.67 is at [some MAC Address]
From: 192.168.2.4, To: 192.168.2.33 --> 192.168.2.4 is at [some MAC Address] Now, when your computer picks those messages up, it knows how many computers are on the subnet 192.168.2.x and what their IP addresses are. From there to getting the computer names would not be hard.
This is just another idea, if you want a more low-level method of solving the problem. In order to send and receive packets from your application, doing a quick article search on CodeProject for "sending packets" or "receiving packets" should pull back some helpful results.
I hope this gives you some ideas; doubtless there are other ways of doing it, and perhaps more efficient than this one.
Sincerely,
Alexander Wiseman
|
|
|
|
|
That's very interesting. Thanks for taking the time to write it!
Josh
|
|
|
|
|
No problem. Thanks for the Active Directory link!
Sincerely,
Alexander Wiseman
|
|
|
|
|
Can anybody confirm what the correct syntax is for using the #ifdef DEBUG statement is?
I am attempting to do something like this:
private bool CheckLogon(string username, string password)
{
#ifdef DEBUG
return true;
#endif
...
snipped code that does release logon checks
...
return checkLogonResult;
}
However this gives a preprocessor directive compiler error.
According to google the syntax above is correct, so I must be committing some stupid mistake
|
|
|
|
|
use #if instead of #ifdef. #ifdef is a C++ directive, not C#.
Josh
|
|
|
|
|
The shame of it
Thanks though
|
|
|
|
|
You beat me to it
Sincerely,
Alexander Wiseman
|
|
|
|
|
|
Hi MrEyes,
If you are using C#, I think the correct way to do this is as follows:
#if _DEBUG
return true;
#endif Your Google search probably returned results which work in C++, but not in C#, unless I am mistaken.
Let me know if that works out.
Sincerely,
Alexander Wiseman
|
|
|
|
|
I need to detect type of network connection that current active on computer (including the IP Address of that connection). I have computer that have two type connection Dialup and LAN (using LAN card). Now I want to know that both connection active or not, because I meet some sample that must send WebRequest to know a network connection that exist or not.
Beside that, if we can detect the Dialup (on LAN card also). How we can know the IP address that received on Dialup, we know that Dialup use DHCP service and the IP address dynamic.
That's all. Thanks for answering.
Regrads,
Ariston Darmayuda.
Simple mind programmers, I don't need a complicated mind.
|
|
|
|
|
This is my code for drawing a set of 8 circles:
private void tbInputTest_Paint(object sender, PaintEventArgs pe)
{
//Get the Graphics object
g = pe.Graphics;
//Create an array of rectangles
Circles = new RectangleF[8];
for (int i = 0; i < 8; i++)
{
Circles[i] = new RectangleF(310, 30+(i * 40), 30, 30);
g.FillEllipse(Brushes.White, Circles[i]);
g.DrawEllipse(Pens.Black, Circles[i]);
}
}
I have a button that when pressed will update the fill color of one of the circle. how i do that? I mean how to propagate the graphic handle toward the whole program. by the way the circles appear on a tab control which make thing not that easy.
Donkaiser
|
|
|
|
|
Use the Invalide method of the control to make it redraw itself.
---
b { font-weight: normal; }
|
|
|
|
|
which invalid method? do u have an example?
Donkaiser
|
|
|
|
|
anyControl.Invalidate();
// If you need an immediate redraw...
anyControl.Update();
// Alternatively, if you're lazy and always want an immediate redraw...
anyControl.Refresh();
Josh
|
|
|
|
|
oh i see. so each time i wanna update sth i need to refresh the display. i thought the paint event keep running in the background. anyway i was trying to implement this:
button1_click(....event e)
{
g.FillEllipse(Brushes.Red, Circles[3]);
g.DrawEllipse(Pens.Black, Circles[3]);
}
g is global type Graphics;
Circles is global type RectangleF[];
but it gave me that i have invalid parameter. why? Please refer to my original code for the on paint code.
Donkaiser
|
|
|
|
|
'g' has probably been disposed of after your Paint event handler is called. Instead of caching the Graphics object you receive in the Paint handler, try calling CreateGraphics() on the TabPage in the Click handler (be sure to call Dispose on that Graphics object when you're finished with it). Draw with that Graphics object instead.
Josh
|
|
|
|
|
donkaiser wrote: i thought the paint event keep running in the background.
No, the paint event is only called when it's needed. If it was running constantly, it would use a huge amount of cpu, and the display would flicker.
---
b { font-weight: normal; }
|
|
|
|
|
Hi world !
I have a strange need today : create an Excel file without Microsoft Office installed on computer.
I work on a WinForm application wrote in C# using .Net 1.1.xxxx.
> I need to be able to create a new .xls file, with some data generated in a progamm loop
> I also need to set the BackGround color for some cells
And the generated file must be directly openable in Excell ( with a double click for exemple : the file is a valid .xls file )
I've think about XML format, but cannot found full description to allow cells BackGroundColor custom.
Thanks in advance if someone have a genius idea ! ...
PS: Sorry if this post isn't in the correct forum ...
Have a nice day.
Sebastien.
|
|
|
|
|
You could look at the open office source for information about how the .xls binary is structured. Good luck. From what I've heard the office binary formats are full of nasty gotchas.
|
|
|
|
|
That's a good idea ! Thanks
... maybe someone have ever write a dll, or ?!
I think browse OpenOffice source code is a big task !!!
Arrghhhh ... Life is hard ...
|
|
|
|
|
I've never used this thing[^] but it looks like it does what you need. Don't yell at me if it sucks!
Josh
|
|
|
|
|
I want to, after deployement of the application, modify the resources of my application. Let say you have a windows form with a button that has a name but you want the user to have the posibility to modify it. Since resources are compile in dll, it is a bit tricky. I have explore two possibilities:
1- I've tried to implement my own resource manager that I would replace in my form where as :
System.ComponentModel.ComponentResourceManager resources = myresourcemanager;
The ComponentResourceManager inherit from ResourceManager and add the ApplyResource method. I can easly derive from ComponentResourceManager, but I have a hard time changing the ResourceManager that it derive from.
I would like to modify only one line of code since it is in the Designer class. And that would leave me the IDE functionnality to generate resources.
I found this article : http://www.codeproject.com/aspnet/customsqlserverprovider.asp that is nice but is for asp and I'm missing information to fill the gap.
2- Uses uncompile resource at runtime that I would be able to modify. I found somewhere that it is possible with asp but didn't find much information about it.
Any ideas?
Thanks
-Archambault
-- modified at 11:59 Thursday 15th June, 2006
|
|
|
|
|
Hi,
When using webservice, I have the time like that:
"2006-06-15T12:10:09Z"
I can't understand it? Is it universal time? "T" & "Z" mean?
Thanks for your help!
Hung
|
|
|
|
|
T is apparently a delimiter between the date and time. Z stands for Zulu which is an alternate name for universal time (UTC), and practically equivilant to GMT. There are a few differences between UTC and the older GMT standard but unless you're a clock geek they're meaningless.
|
|
|
|