|
Personally, I write the constructors for my Windows Services to take a parameter for its name (and other information). And I do very little in the OnStart handler.
|
|
|
|
|
Hi.
can anyone help me with a small application (I'm thniking a C# console application) that has to:
- Read a .txt file, where a lot (4-500) host names a listed
- ping all the hosts and return the result with:
Hostname, IP_Address, OS Version/Type and Date (The date is the time where the host was "pinged".
This information must be inserted into a database, and the datetime must be overwritten unless if the host does not answer - then the host and the date where it did not answer must be inserted into another table.
I havent done any programmeing with networking so if any one could help me out I'll be very happy.
Also, if there is any questions you just let me know.
Thanks in advance.
\Jan.
|
|
|
|
|
That's not a big deal, I do a couple of things that are similar, one in a Windows Services.
Reading a text file is easy enough, but I prefer XML, or (prefereably) read from the database.
To ping you can use:
System.Net.NetworkInformation.PingReply result = (new System.Net.NetworkInformation.Ping()).Send ( HostName , 1000 )
Then write to the database.
|
|
|
|
|
OK, I'll try that.
Thanks for your answer, but is it possible that you have an example that I can see?
\Jan.
|
|
|
|
|
There is not MeasureItem event for Listview so how can i draw a blank row or keep a distance between each item on DrawItem. Thanks
|
|
|
|
|
From what I can see on google, the only way to change the height of a listviewitem is to create a bitmap that's the right height and make it show in the listviewitem in question.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Is there any simple example
|
|
|
|
|
I got the answer now if you change the listview font size then it adds spaces between rows but this is so stupid of microsoft why would anybody wants to do this way. It also means that all rows would have the same distance.
There isn't anywhere on the .net framwork tells that on DrawItem you cant change the rows size. This is absolutely a nightmare who beginners. any suggestions guys.
|
|
|
|
|
If you were to google this, you'd find that others have had the same problems. At hte core, winforms is just a wrapper on controls that have been there forever, until you move to WPF, you are tied to something that is pretty old now.
Also, the imagelist solution ( which I think is far more robust that changing the font size ) is widely documented on the web.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Plssssssss read the first message in the forum titled "How to get an answer to your question". Pay attention to item #2
led mike
|
|
|
|
|
|
At least he didn't SHOUT PLEEEEEEEEEAAAAAAAASSSSSSEEEEE
codito ergo sum
|
|
|
|
|
Nor did he demand that the code should be sent to his email urgently...
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
How can I make a sliding form in vb6.0 or .Net 1.1 using VB.Net and C#?
joel.r.paderagao
|
|
|
|
|
joel.paderagao wrote: How can I make a sliding form in vb6.0 or .Net 1.1 using VB.Net and C#?
Try changing the Form.Location property value.
led mike
|
|
|
|
|
Okey Thanks, But What I mean is I want to know the code for that. Tnx
joel.r.paderagao
modified on Thursday, February 14, 2008 7:18 PM
|
|
|
|
|
This forum is only designed to help you solve a problem, it is a not a rent-a-coder forum, especially since we don't get paid. Sometimes people will post a snippet if it helps explain the solution better, but in this case the answer given should be good enought for you to be able to figure the rest out.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Okey Thanks and God Bless!!!
joel.r.paderagao
|
|
|
|
|
Hi, I'm relatively new to C# (C++/C/Java background) and I'm having a difficult time getting through an interop issue. I'm attempting to call a function located in a native C++ dll, but the following exception is thrown:
"Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
I suspect I am handling the byte * wrong. I have tried several things including marshaling, but all yield the same result. Any help would be greatly appreciated. Here is the relevant information.
C++ declaration (within a dll):
int foo(const BYTE *a, int b)
My C# declaration:
[DllImport("bar.dll", EntryPoint = "foo", CharSet = CharSet.Auto)]
public static extern unsafe int foo(byte* a, int b);
The relevant code:
// taken from a function declared unsafe
int ret;
byte[] buffer;
buff = new byte[20];
// ... fill the buffer with stuff ...
fixed (byte* bPtr = buff)
{
// the following line causes the exception
ret = foo(bPtr, buff.Length);
}
Thanks again,
-J
|
|
|
|
|
I thought that the variable you pointed to had to be fixed, but not the pointer. I think you need to declare buff as,
fixed byte[] buff = new byte[20]; If that doesn't work, then perhaps you should try the following:
IntPtr bytePtr = Marshal.AllocHGlobal(20);
try {
ret = foo((byte*)bytePtr.ToPointer(), 20);
} finally {
Marshal.FreeHGlobal(bytePtr);
} Or perhaps the argument to your method foo is supposed to be 19 in this case instead of 20. Hope one of these suggestions helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
protected override void OnMouseUp(MouseEventArgs e)
{
int WM_CONTEXTMENU = 0x7B;
this.Capture = false;
Message msg = Message.Create(this.Handle, WM_CONTEXTMENU, ???, ???);
DefWndProc(ref msg);
}
=========================================
Dear Sir And Madam,
The code above....
I need to show Windows Form Title Bar Context Menu.
Message msg = Message.Create(this.Handle, WM_CONTEXTMENU, ???, ???);
What parameter I should create and pass to Message.Create method.
Sorry for bad English.
Thank You.
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DateSelectionforPGE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
selectDate();
connectSQl();
}
public void connectSQl()
{
SqlConnection conObj = new SqlConnection("Server=localhost;Integrated security=SSPI;database=master");
conObj.Open();
}
public void selectDate()
{
//To take the Database Name
string nameDatabase = dateTimePicker1.Value.ToString("MMdd");
string nameDB = "CustList_PGE_" + nameDatabase;
MessageBox.Show("The name of the database will be CustList_PGE_" + nameDatabase);
//To take the Database Table
string nameDatabasetable = dateTimePicker1.Value.ToString("MMddyy");
string nameTable = "CustList_PGE" + nameDatabasetable;
MessageBox.Show("The name of the Database table will be CustList_PGE" + nameDatabasetable);
//Connecting to the Stored Procedure
SqlCommand cmdObj = new SqlCommand();
cmdObj.CommandText = "CreateDataBases";
cmdObj.CommandType = CommandType.StoredProcedure;
cmdObj.Parameters.AddWithValue("@databaseName", nameDB);
cmdObj.ExecuteNonQuery();
}
}
}
|
|
|
|
|
I have a config class that is decorated using attributes from System.Xml.Serialization, so reading of the configuration files is easy. There are dozens of instances of those configuration files, which are loaded on demand specifying the file name to indicate which instance we want.
I want to change this in the following way: instead of the clients of the class instantiating a new instance of XmlSerializer each time, specifying the file name, I want to encapsulate it as a static member instance, created on class initialization. Then, I want to provide a static method, member of the config class, that will take a file name and return the appropriate instance.
Now that you have the context, here is the question: since the XmlSerializer is a static member and more than one thread can call the static method to get an instance at the same time, is the XmlSerializer.Deserialize method thread-safe?
Thank you.
|
|
|
|
|
Hello,
I'm also not sure about this one.
Out of a feeling I would asume it is not.
Therfore I would implement a static Deserialize method ans use a lock[^] statement there.
All the best,
Martin
|
|
|
|