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
- Meload data besar dalam dbgrid
- Melarang "Tutup" Aplikasi, kecuali shutdown/restart
- Menentukan Harga Proyek
- Membuat MP3 Compressor Sendiri
- Rilis Lazarus 2.0.8
- Membuat kontrol db aware
- Menampilkan nama bulan dalam bahasa Indonesia dalam fungsi "FormatDateTime"
- Photoshop Remote Control dengan Delphi
- Mengenal OXYGENE – Pascal For .NET
- Referensi Pemrograman Bahasa Pascal dari Tim Pembina TOKI
Last Articles
Recent Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago