Programmation systeme

thekidd Messages postés 4 Date d'inscription lundi 1 juin 2015 Statut Membre Dernière intervention 24 juin 2015 - 1 juin 2015 à 15:46
thekidd Messages postés 4 Date d'inscription lundi 1 juin 2015 Statut Membre Dernière intervention 24 juin 2015 - 24 juin 2015 à 19:58
je cherche à intercepter la suppression d'un fichier , répertoire ou autres. c'est à dire que je veux stopper la suppression et remplacer par mon propre code. Aidez-moi s'il vous plait

6 réponses

blackduck Messages postés 817 Date d'inscription mercredi 20 février 2013 Statut Membre Dernière intervention 24 novembre 2018
1 juin 2015 à 16:36
Tu cherches à faire en sorte que lorsqu'une commande rm est lancée ça exécute autre chose?
0
thekidd Messages postés 4 Date d'inscription lundi 1 juin 2015 Statut Membre Dernière intervention 24 juin 2015
3 juin 2015 à 10:28
Désolé de répondre que maintenant.En effet , je cherche un moyen de recycler les fichiers supprimés sur un partage réseau. Car souvent les fichiers supprimés sur les partages disparaissent. c'est à dire que je veux créer une corbeille réseau AVEC C#
0
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
5 juin 2015 à 13:50
Salut,

Places un objet FileSystemWatcher sur un répertoire
et implémentes ls events ceated, deleted, ect...

Le FileSystemWatcher (assembly System.IO) notifie les applis qui l'utilise pour logger ou intervenir sur le fichier/repertoire sans avoir besoin de boucle, de timer ou de hook.

bye...
0
Le probleme c'est que Filessystemwatcher ne sert que surveillance de reperoire ou fichier. C'est-à-dire qu'il informe simplement quand il y a changement ou suppression. il ne peut pas arreter la suppresion
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
thekidd Messages postés 4 Date d'inscription lundi 1 juin 2015 Statut Membre Dernière intervention 24 juin 2015
Modifié par Whismeril le 15/06/2015 à 12:44
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.
0
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 656
15 juin 2015 à 12:44
EDIT: Ajout de la coloration syntaxique.
0
thekidd Messages postés 4 Date d'inscription lundi 1 juin 2015 Statut Membre Dernière intervention 24 juin 2015
24 juin 2015 à 19:58
Pouvez vous m'aider sur l'utilisation de Icopyhook c#
0
Rejoignez-nous