السلام عليكم
ممكن طريقة اضافة اسماء الاجهزه الموجوده بالشبكه الى الاداه ComboBox
وذلك لاستخدام الامر net send الذي يقوم بارسال رساله الى الاجهزه المحليه
وشكرا
السلام عليكم
ممكن طريقة اضافة اسماء الاجهزه الموجوده بالشبكه الى الاداه ComboBox
وذلك لاستخدام الامر net send الذي يقوم بارسال رساله الى الاجهزه المحليه
وشكرا
abo_alzobaer@hotmail.com
هو فيه طريقة أنا أستخدمها عندما أريد قراءة نتائج أي أمر أرسله في الدوت في برنامجي و هي وضع النتائج في ملف نصي ثم بعد ذلك قراءته من برنامجي و الطريقة كالتالي (لوضع النتيجة في ملف نصي)
هذا كود تضعه في Button و يجب على الفورم التي تشتغل عليها ان تحتوي على textBox1 لكتابة أمر الدوس و textBox2 لعرض النتيجة
private void button1_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("cmd.exe","/c " + textBox1.Text+ @" >> c:\MyDosCommand.txt");
StreamReader ReadFile = new StreamReader("c:\\MyDosCommand.txt");
textBox2.Text=ReadFile.ReadToEnd();
}طبعا يمكنك التعامل مع النتيجة كما تريد و أنا أسف لأني لم أعرض لك حلا كاملا لكني مشغول في هذه اللحظة ... المهم لو كان فيه أي استفسار انا تحت أمرك
والسلام عليكم
اخي الكريم
انا الي اريده هو اضافة جميع عناصر شبكة الاتصال على combo box
لاستخدم الامر net send
يعني الامر راح يكون كذا
net send comboBox1..text hellow
ارجو ان تكون وصلت الفكره
abo_alzobaer@hotmail.com
أيوة لكن أولا يجب عليك معرفة الأجهزة الموجودة على الشبكة ثم وضعها في ال Combo (و هذا ما يمكنك عمله بالمثال الذي أعطيتك اياه فقط ببعض التعديلات) و تبقى الخطوة الأخير و هي التي ذكرتها و هي سهلة للغاية
مافي طريقة اسهل من كذا
يعني مفي كلاس او داله او اداه
لان المثال التالي يفتح ال cmd ثم يغلقه
وطلع لي رسالة خطأ لانه ماتعرف على الملف c:\\MyDosCommand.txt
ياريت لو توضح اكثر
thanks
abo_alzobaer@hotmail.com
هناك Namespace بالدوت نت اسمه System.Net يساعدك على التعامل مع الشبكات...
جرب هذه الوصلة:
Getting a list of computer names on the local network و قم بتحميل المثال، و يمكنك تحويله من الـ VB.Net للـ #C بكل سهولة...
رأس الحكمة الإيمان بالله
اشكرك اخ محمد
انت حليت المشكله
بس كيف اقوم بامر الnet send اذا كان اسم الجهاز مثلا pc1
انا بحثت في msdn وما لقيت الحل
ياليت تفيدني
تم تعديل هذه المشاركة بواسطة mgazif في 24 يوليو 2005 في 17:50
abo_alzobaer@hotmail.com
اقتباسObtaining the list of Users using C#When managing a network it is also important what we have a accurate list of the users on the network, or local machine. To obtain this we must use the NetUserEnum function, which returns the names and data elements of each user area to structures. In this case we are going to use the USER_INFO_0 structure to pass the return values into, simply because we are only trying to get usernames no other data i have added this in the declarations section. It is also important to note that this function uses the network buffer, which must be freed after, to free resources, this is done using the NetAPIBufferFree function also listed. To start with in this code snippet is the declarations.
///// CODE SNIPPET 2.1 Declarations
[structLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct USER_INFO_0
{
public String Username;
}
[DllImport("Netapi32.dll")]
extern static int NetUserEnum([MarshalAs(UnmanagedType.LPWStr)] string servername, int level, int filter, out IntPtr bufptr, int prefmaxlen, out int entriesread, out int totalentries, out int resume_handle);
[DllImport("Netapi32.dll")]
extern static int NetApiBufferFree(IntPtr Buffer);
//// END OF CODE
Once we have made the declaration we can go out and use our code, to create the collection of the users, to do this we use the below code snippet.
///// CODE SNIPPET 2.2 NetUserEnum (Some code attributed by Nick Holmes)
int EntriesRead;
int TotalEntries;
int Resume;
IntPtr bufPtr;
NetUserEnum(null, 0, 2, out bufPtr, -1, out EntriesRead, out TotalEntries, out Resume);
if(EntriesRead> 0)
{
USER_INFO_0[] Users = new USER_INFO_0[EntriesRead];
IntPtr iter = bufPtr;
for(int i=0; i < EntriesRead; i++)
{
Users = (USER_INFO_0)Marshal.PtrToStructure(iter, typeof(USER_INFO_0));
iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(USER_INFO_0)));
MessageBox.Show(Users.Username);
}
NetworkAPI.NetApiBufferFree(bufPtr);
}
//// END OF CODE
The above code intern returns each use listed on the local machine via MessageBox, as with all other function you can chose a remote computer again by replacing the null string.
To send msgs to network users
u can use this tool in ur application or examine the source code to write ur own
:)
take note that the first example doesnt require active directory to be installed !
انا كل الي اريده هو هذا الكود:
[DllImport("NetApi32")] public static extern int
NetMessageBufferSend(uint ServerName,uint MsgName, uint FromName,uint Buffer,ulong BufferLen);ما ادري هل هو دالة api ام ماذا
المثال كله يعتدمد على دالة الارسال هذه
ياريت حد يقول هل هذه api ولا لا
واسف على الازعاج
abo_alzobaer@hotmail.com
اسف :)
نسيت اقول انها دالة WIN32 API
موجوده في ال Network Management Library
و ما تنساش تستخدم
using System.Runtime.InteropServices;
تم تعديل هذه المشاركة بواسطة Eclipse في 24 يوليو 2005 في 20:37
هذا الموضوع مغلق.