Hi, everybody!

DMD32 D Compiler v2.067.0
I try to cause the fputc function from CrtDLL.DLL and I receive a mistake. Why?

import core.runtime;     // Загрузка DLL Для Win
import std.stdio;        // writeln

version(Windows) {
        import std.c.windows.windows;  // GetProcAddress для Windows
}

alias extern (C) int function(int, FILE*) t_fputc; t_fputc ms_fputc;

int main(string[] args) {

version(Windows) {    auto libCrtDll = "CrtDll.dll";   }

        // Load CrtDLL.DLL MS Windows
    auto h = Runtime.loadLibrary(libCrtDll);
        // Find function fputc
    ms_fputc = cast(t_fputc)GetProcAddress(h, "fputc");
        
        import core.stdc.stdio: stdout;
        try {
                auto rez = ms_fputc('A' , core.stdc.stdio.stdout);
    }
        catch {
                writeln("Error execute MS function fputc();");
        }
    return 0;
}

Reply via email to