salut, J'ai avec moi un bout de code pemettant d'intercepeter le double clic du boutton gauche de la sourris. Avec WM_LDBLCLICK. WM = windows message. Mais, quel evenement intercepter quand la suppression se fait ? .
Ce code marche à merveille même en dehors du formulaire.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace de
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms
designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
public enum HookType : int
{
WH_JOURNALRECORD = 0,
WH_JOURNALPLAYBACK = 1,
WH_KEYBOARD = 2,
WH_GETMESSAGE = 3,
WH_CALLWNDPROC = 4,
WH_CBT = 5,
WH_SYSMSGFILTER = 6,
WH_MOUSE = 7,
WH_HARDWARE = 8,
WH_DEBUG = 9,
WH_SHELL = 10,
WH_FOREGROUNDIDLE = 11,
WH_CALLWNDPROCRET = 12,
WH_KEYBOARD_LL = 13,
WH_MOUSE_LL = 14
}
[DllImport("user32.dll")]
static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc callback, IntPtr
hInstance, uint threadId);
[DllImport("user32.dll")]
static extern bool UnhookWindowsHookEx(IntPtr hInstance);
[DllImport("user32.dll")]
static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, int wParam, IntPtr lParam);
[DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string lpFileName);
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
const int WH_KEYBOARD_LL =13;
const int WH_MOUSE_LL =14;
const int WH_CBT =5;
// ????? ??????????? LowLevel-???? ?? ??????????
const int WM_KEYDOWN = 0x100; // ????????? ??????? ???????
const int WM_COPY = 0x0301;
const int WM_LBUTTONDBLCLK = 0x0204;
private LowLevelKeyboardProc _proc = hookProc;
private static IntPtr hhook = IntPtr.Zero;
public void SetHook()
{
IntPtr hInstance = LoadLibrary("User32");
hhook = SetWindowsHookEx(WH_MOUSE_LL, _proc, hInstance, 0);
}
public static void UnHook()
{
UnhookWindowsHookEx(hhook);
}
public static IntPtr hookProc(int code, IntPtr wParam, IntPtr lParam)
{
if (code >= 0 && wParam == (IntPtr)WM_LBUTTONDBLCLK )
{
MessageBox.Show(wParam.ToString());
return (IntPtr)1;
}
else
return CallNextHookEx(hhook, code, (int)wParam, lParam);
}
void Button2Click(object sender, EventArgs e)
{
}
void MainFormLoad(object sender, EventArgs e)
{
SetHook();
}
void MainFormFormClosing(object sender, FormClosingEventArgs e)
{
UnHook();
}
}
}
Désolé c'est un peu long
Il y a aussi un logiciel qui sert de corbeille pour les disques amovibles appelé IBIN. je crois que le principe du corbeille réseau est le même. Mais l'un sur un partage et l'autre sur un disque.