skrip ini digunakan untuk menutup aplikasi lain yang sedang berjalan, dengan kondisi: hanya HInstance-nya saja yang diketahui.
interface uses WinTypes; procedure CloseAppFromInst(HInst: THandle); implementation uses WinProcs, Messages; { Callback function that has each top-level window passed to it. } { Return true to continue enumerating, false to stop. } function EnumWindowsProc(Handle: HWND; Info: Pointer): boolean; {$IFDEF WIN32} stdcall; {$ELSE} export; {$ENDIF} begin Result := TRUE; { continue enumeration } { Does this app have the same instance as what we are looking for? } {$IFDEF WIN32} if GetWindowLong(Handle, GWL_HINSTANCE) = LongInt(Info) then begin {$ELSE} if GetWindowWord(Handle, GWW_HINSTANCE) = LongInt(Info) then begin {$ENDIF} PostMessage(Handle, WM_CLOSE, 0, 0); { Close the app } Result := FALSE; { stop enumerating windows, we are done. } end; end; procedure CloseAppFromInst(HInst: THandle); begin EnumWindows(@EnumWindowsProc, LongInt(HInst)); end; end. |
red: Provided by Duncan McNiven
Random Articles
- Menambahkan skrolbar horisonal pada listbox
- Antisipasi penekanan tombol Back di Android dengan Delphi
- Tulis/Baca "string" di file .INI
- Image JPG di MySQL
- EXE/PE File Protector
- Folder SIZE
- Minimize secondary-form ke taskbar
- Menampilkan Aplikasi Yang Berjalan (visible)
- Deteksi Perubahan Modus Video (layar)
- easily load all kind of images (Gif, Ico, Jpeg and more) in a TImage
Last Articles
- Project Group dalam Lazarus
- FastPlaz Database Explorer
- Release: FastPlaz Super Mom v0.12.22
- PascalClass #3: Web Development with Free Pascal
- Makna Pascal di Pascal Indonesia
- Kulgram : Instalasi Lazarus di Perangkat Berbasis ARM
- PascalClass #1: Analisa Database dan Machine Learning
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
- Mengenal OXYGENE – Pascal For .NET
- PascalTalk #5: UX: Research, Design and Engineer
Recent Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 months ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 1 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 8 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 8 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 8 years ago