Jump to content

Usb Algılama Programı


Shain_K
 Share

Recommended Posts

USB leri 3 dakikada bir kontrol eden ve taşınabilir bir depolama aygıtı takıldığı nalaşıldığında “Depolama aygıtınızı unutmayınız” diye 5 dakikada bir sesli uyarı veren program yapmak istiyorum.şu ana kadar usb algılama olayını hallettim fakat timer kullanımını yapamadım yardımcı olurmusunuz?

 

kodum:

[spoiler]public partial class Form1 : Form
{

bool usbhazir = true;

public Form1()
{
InitializeComponent();
}



protected override void WndProc(ref Message m)
{
if (m.Msg == 0x219)
{
usbhazir = true;
}
else
{
usbhazir = false;
}
base.WndProc(ref m);


}

private void button1_Click(object sender, EventArgs e)
{
if (usbhazir)
{
MessageBox.Show("Bir Usb Algılandı.");
}
else
{
MessageBox.Show("Bir Usb Algılandı.");
}
}
}
}[/spoiler]

Link to comment
Share on other sites

  • Editor

Bu usb tetiklemesi yaptıktan sonra WMI ile sadece usb storage leri getirip algılanabilir tabi bu şuan için basit biz çözüm diyorum. Akşam eve geçtiğimde bi bakarım.


Burada güzel bir örnek var.

 

http://stackoverflow.com/questions/6003822/how-to-detect-a-usb-drive-has-been-plugged-in

Link to comment
Share on other sites

timer için bir örnek hazırladım: https://yadi.sk/d/HPNgnnVyh3TZ9

 

burada önemli olan interval değeri. Interval'i 1000 ms yani 1 saniye de bir çalışacak şekilde ayarladım. 3 dakika istiyorsanız 3 x 60 x 1000 = 180.000 Ms  (dakika x saniye x milisaniye) olarak ayarlaman gerekiyor yani intervali 180000 ms olarak ayalarsan 3 dakikada bir eventdaki olayı gerçekleştirecektir.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...