- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
Hướng dẫn viết ứng dụng ẩn - hiển thị và xóa nút đóng chương trình khác (hide and show and remove close button another application)
Hôm nay, mình xin hướng dẫn các bạn cách ẩn và hiển thị ứng dụng chương trình khác.
Ví dụ: Tôi muốn viết 1 ứng dụng, có thể ẩn hoặc hiện chương trình microsoft word (hoặc xóa biểu tượng đóng trên chương trình ms Word)
Các bạn có thể xem demo chương trình như hình bên dưới:
Các bạn có thể sử dụng thủ thuật này, để viết ứng dụng khóa và mở khóa ứng dụng.
Ví dụ: khi bạn mở chương trình zalo trên desktop lên thì yêu cầu phải nhập mật khẩu, nếu mật khẩu đúng mình sẽ cho phép hiển thị ứng dụng zalo.
Source code chương trình:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll")]
static extern bool DeleteMenu(IntPtr hMenu, uint uPosition, uint uFlags);
const uint SC_CLOSE = 0xF060;
const uint MF_BYCOMMAND = 0x00000000;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e){
var handle = FindWindow(null, "Document1 - Microsoft Word");
ShowWindow(handle, 0);
}
private void button2_Click(object sender, EventArgs e)
{
var handle = FindWindow(null, "Document1 - Microsoft Word");
ShowWindow(handle, 1);
}
private void button3_Click(object sender, EventArgs e)
{
Process[] processes = Process.GetProcessesByName("winword");
foreach (Process p in processes)
{
IntPtr pFoundWindow = p.MainWindowHandle;
IntPtr nSysMenu = GetSystemMenu(pFoundWindow, false);
if (nSysMenu != IntPtr.Zero)
{
if (DeleteMenu(nSysMenu, SC_CLOSE, MF_BYCOMMAND))
{
MessageBox.Show("dfsdf");
}
}
}
}
}
}
CHÚC CÁC BẠN THÀNH CÔNG