Bonjour,

Voici mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
 
namespace GameStarter
{
    public class Program
    {
 
        private delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
 
        private 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")]
        private static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
 
        [DllImport("user32.dll")]
        private static extern int CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
 
        // Initialization
 
        public static void Main(string[] args)
        {
            new Program();
        }
 
        public Program()
        {
            HookProc proc = new HookProc(CallBack);
            SetWindowsHookEx(HookType.WH_KEYBOARD, proc, IntPtr.Zero, AppDomain.GetCurrentThreadId());
        }
 
        private int CallBack(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code < 0)
            {
                return CallNextHookEx(IntPtr.Zero, code, wParam, lParam);
            }
            else
            {
                Keys keyPressed = (Keys)wParam.ToInt32();
                Console.WriteLine("KeyPressed:" + keyPressed);
                return CallNextHookEx(IntPtr.Zero, code, wParam, lParam);
            }
        }
    }
}
et voici l'erreur

Accessibilité incohérente*: le type de paramètre 'MyClass.HookProc' est moins accessible que la méthode 'MyClass.SetWindowsHookEx(MyClass.HookType, MyClass.HookProc, System.IntPtr, int)'
Je n'arrive pas à la corriger, peut on m'aider?

Merci.