On 6/7/15 12:41 PM, MGW wrote:
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;
}
DMD 32-bit does not use MSVC runtime, it uses DMC (Digital Mars C++
Compiler) runtime. So you cannot use MSVC versions of C runtime.
You can use Win32 system calls, though.
-Steve