PDA

View Full Version : مبتدی: سورس کد سی شارپ



hussin
چهارشنبه 05 بهمن 1390, 16:03 عصر
چگونه مسیر اجرایی برنامه را بدست آوریم؟


string appPath = Application.Executablepath;



چگونه بفهمبم کدام سیستم عامل در حال اجراست؟


OperationgSystem os = Environment.OSVersion;

MessageBox.Show(os.Version.ToString());

MessageBox.show(os.Platform.ToString());


چگونه یک ComboBox را با فونت های سیستم پر کنیم؟


ComboBox1.Items.AddRange(FontFamily.Families);




چگونه با استفاده از کد نویسی ، متن های چند خطی (Multiline) را در یک جعبه متن(TextBox) قرار دهیم؟


String[] strAddress As String() = {"C#‎.NET" , "Is Great.,".NET" , "Is sasolute great."};

TextBox1.Multiline = true;

TextBox1.Lines = steAddress;


چگونه اتصال به اینترنت را با استفاده از دات نت قطع کنیم؟


System.Net.NetworkInformation.NetworkInterface

adapters = new_

System.Net.NetworkInformation.NetworkInterface.Get AllNetworkInterfaces();

foreach

(System.Net.NetworkInformatin.NetworkInterface

adapter in_adapters)

{

Shell("cmd /c Rasdial " & adapter.Name & "/Disconetct" , AppWinStyle.Hide);

}


چگونه یک فایل صوتی موجود بر روی هارد دیسک را پخش کنیم؟


Sysetm.Media.SoundPlayer player = new

System.Media.SoundPlayer();

String path = " the path of the file to be played";

player.SoundLocation = path;

player.play();


چگونه IP کامپیوتر Local را بدست آوریم؟


PAddress [] ipList = Dns.GetHostAddresses(Dos.GetHostName());

foreach (IPAddress ip in ipList)

MessageBox.Show(ip.ToString());


چگونه سی دی رام را باز و بسته کنیم؟



using System.Runtime.InteropServices;
using System.Text;
...
public static void Main( )
**
int result = mciSendString
("set cdaudio door open", null, 0, IntPtr.Zero);
result =
mciSendString ("set cdaudio door closed",
null, 0, IntPtr.Zero);
**

[DllImport("winmm.dll", EntryPoint="mciSendStringA", CharSet=CharSet.Ansi)]
protected static extern int mciSendString
(string mciCommand,
StringBuilder returnValue,
int returnLength, IntPtr callback);

modern_amin
چهارشنبه 05 بهمن 1390, 16:11 عصر
اینم یک لینک بدرد بخور برا کسانی که دنبال اینجور کدها ها هستند
http://www.aghazeh.com/programing-language-ebooks/606-noktehaye-c.html