- [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
[C#] Viết ứng khóa lock windows lập trinh csharp
Nhiều lúc các bạn muốn tích hợp thêm chức năng lock windows trong ứng dụng nên bài viết này mình sẽ hướng dẫn các bạn viết một ứng dụng khóa lock windows trong lập trình C#.
- Để lock window trong lập trình C# chúng ta có 2 cách để sử dụng:
Cách 1: Bạn viết code như sau
[DllImport("user32.dll")]
public static extern bool LockWorkStation();
private void button1_Click(object sender, EventArgs e)
{
LockWorkStation();
}
Cách 2: sử dụng process start
Process.Start(@"C:WINDOWSsystem32
undll32.exe", "user32.dll,LockWorkStation");
FULL SOURCE LOCK WINDOWS C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
public static extern bool LockWorkStation();
private void button1_Click(object sender, EventArgs e)
{
LockWorkStation();
}
private void button2_Click(object sender, EventArgs e)
{
Process.Start(@"C:WINDOWSsystem32
undll32.exe", "user32.dll,LockWorkStation");
}
}
}
HAPPING CODING