I'm trying to make something in C# that requires calling into some unmanaged DLLs, a process which I know nothing about! I found a "Hello World" tutorial that should be as simple as copying and pasting a couple lines of code from the bottom:
using System;
using System.Runtime.InteropServices;
namespace PInvokeTest
{
class Program
{
[DllImport("msvcrt40.dll")]
public static extern int printf(string format, __arglist);
public static void Main()
{
printf("Hello %s!\n", __arglist("World"));
Console.ReadKey();
}
}
}
This compiles and runs to completion without any errors, however nothing is printed by the time it gets to the ReadKey()
.
Did I miss some important setup step? The project builds for .NET 4.6.1 (in case that matters for DLL versioning or something).
printf
does that automatically, then no. Can I flush from C#, or do I have to add another PInvoke signature for a flush method? What would that look like? – Nonentity