Pinvoke msdn platform tutorial

Below is a tutorial from msdn . The output of _flushall is the โ€œTestโ€ in the tutorial, but I got a โ€œ2โ€ by displaying the output using console.write (). Can someone explain please?

using System;
using System.Runtime.InteropServices;

class PlatformInvokeTest
{
    [DllImport("msvcrt.dll")]
    public static extern int puts(string c);
    [DllImport("msvcrt.dll")]
    internal static extern int _flushall();

    public static void Main() 
    {
        puts("Test");
        _flushall();
    }
}
+4
source share
1 answer

This code no longer works on modern versions of Windows. The version of "msvcrt.dll" you received is a private CRT implementation for Windows executables that has been subjected to unnecessary misunderstanding, possibly something related to security.

, . , โ€‹โ€‹Visual Studio 2010 . c:\windows\syswow64 msvcrxxx.dll, xxx - 100, 110 120. . VS2013:

[DllImport("msvcr120.dll")]
public static extern int puts(string c);
[DllImport("msvcr120.dll")]
internal static extern int _flushall();

:

+6

Source: https://habr.com/ru/post/1529225/


All Articles