Jump to content

Command Line


korasoglu
 Share

Recommended Posts

Öncelikle command line parametresi şudur;

 

- dos penceresinden bir uygulamaya parametre göndermek. örn: C:\dosya.exe /silent

- bir dosyayı sürükle bırak yöntemiyle bir uygulamanın üzerine taşıyarak birlikte aç işlemi yapmak

 

Bunun bir kaç farklı yolu var sanırım. En kolay yol şudur:

 

Program.cs dosyasındaki

        static void Main()

fonksiyonuna string[] yani dizi array tipinde parametre ekleriz.

        static void Main(string[] args)

bu parametre ile dışarıdan gelen tüm parametreleri alabiliriz. ister bunu Program.cs içinde kullanabilir istersek başka formlara aktarabiliriz. 

 

Ben ekteki örnekte Form1'e public static yapısında (diğer formlar ve class'lardan erişilebilen) bir string tanımladım ve Program.cs'ye gelen parametreyi bu public string'e aktardım. Daha sonra bunu Form1'de alarak ekrana yazdırdım.

https://yadi.sk/d/qpE-yjEYkdpvN
Link to comment
Share on other sites

Ben programın çlıştığını biliyorum ama kapatamıyorum.

 

bool prog;
Mutex mtx = new Mutex(true, "asd", out prog);
if (!prog)
{
MessageBox.Show("Bu program zaten çalışıyor.", "Uyarı!", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
GC.KeepAlive(mtx);

Link to comment
Share on other sites

Hocam resim görüntüleme programı yaptım. Resme tıkladığım zaman hazırladığım uygulama ile açılıyor fakat tekrar bir resme tıkladığım zaman açık olanı kapatıp yeniden yüklemesini istiyorum. Yani bir pencere olmasını istiyorum.

 

Ams de şöyle yapmıştım Program açıkken işlem numarasını iniye yazdırdım.

 

baktim = INIFile.GetValue(_SourceFolder.."\\aa\\Ayar.ini", "Devam", "1");
windows = Window.EnumerateTitles();
window_name = "Resim Gosterici";
for handle, title in pairs(windows) do
    result = String.Find(title, window_name, 1, false);
    if (result ~= -1) then
    --Dialog.Message("Hata", "Program zaten çalışıyor!", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
System.TerminateProcess(baktim);
    end
end
 
Ve işimide gördü.
Edited by korasoglu
Link to comment
Share on other sites

Hayır sorun çözülmedi


İstediğim buydu işine yarayan olursa

using System.Diagnostics;

            Process[] prg;
            prg = Process.GetProcessesByName("CommandLine_Ornegi");
            if (prg.Length > 1)
            prg[0].Kill();

Peki picturebox sa dragdrop nasıl yapabilirim google gösterilenleri deniyorum olmadı

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...