Beispiel #1
0
        public static void Main(string[] args)
        {
            CdeclCallback   cdecl      = TestCallback;
            StdcallCallback stdcall    = TestCallback;
            IntPtr          cdeclPtr   = Marshal.GetFunctionPointerForDelegate(cdecl);
            IntPtr          stdcallPtr = Marshal.GetFunctionPointerForDelegate(stdcall);

            Console.WriteLine(TakesCdecl(cdecl));
            Console.WriteLine(TakesStdcall(stdcall));
            Console.WriteLine(TakesCdecl2(cdeclPtr));
            Console.WriteLine(TakesStdcall2(stdcallPtr));

            Console.WriteLine("Press enter to cross the callbacks, will cause a crash due to stack imbalance.");
            Console.ReadLine();

            Console.WriteLine(TakesCdecl2(stdcallPtr));
            Console.WriteLine(TakesStdcall2(cdeclPtr));

            Console.WriteLine("Done.");
            Console.ReadLine();
        }
 private static extern void StdcallCallbackTest(StdcallCallback callback);
Beispiel #3
0
 private static extern int TakesStdcall(StdcallCallback callback);