digitalmars.D.learn - How to get normal DLL method name
- Denis Mezhov (45/45) Feb 15 2014 DLL
- Denis Mezhov (13/13) Feb 15 2014 Sorry
- Stanislav Blinov (7/20) Feb 15 2014 How about this:
- Denis Mezhov (60/60) Feb 15 2014 Don't work
- Denis Mezhov (7/67) Feb 15 2014 Oh, sorry
- Mike Parker (2/7) Feb 16 2014 I'm curious why you're declaring your main method as extern(Windows).
DLL module dllmain; import std.c.windows.windows; import core.sys.windows.dll; import core.stdc.stdio; __gshared HINSTANCE g_hInst; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { final switch (ulReason) { case DLL_PROCESS_ATTACH: g_hInst = hInstance; dll_process_attach( hInstance, true ); break; case DLL_PROCESS_DETACH: dll_process_detach( hInstance, true ); break; case DLL_THREAD_ATTACH: dll_thread_attach( true, true ); break; case DLL_THREAD_DETACH: dll_thread_detach( true, true ); break; } return true; } export void dllprint() { printf("hello dll world\n"); } In Main FARPROC fp = GetProcAddress(h, "dllmain"); // Not work if fp is null) { printf("error loading symbol()\n"); } FARPROC fp = GetProcAddress(h, "D7dllmain8dllprintFZv"); // It work if fp is null) { printf("error loading symbol()\n"); } How i set/get normal name in DLL?
Feb 15 2014
Sorry // Not work FARPROC fp = GetProcAddress(h, "dllprint"); if fp is null) { printf("error loading symbol()\n"); } // It work FARPROC fp = GetProcAddress(h, "D7dllmain8dllprintFZv"); if fp is null) { printf("error loading symbol()\n"); }
Feb 15 2014
On Sunday, 16 February 2014 at 00:46:13 UTC, Denis Mezhov wrote:Sorry // Not work FARPROC fp = GetProcAddress(h, "dllprint"); if fp is null) { printf("error loading symbol()\n"); } // It work FARPROC fp = GetProcAddress(h, "D7dllmain8dllprintFZv"); if fp is null) { printf("error loading symbol()\n"); }How about this: // in dll: extern(C) void dllprint() { /* ... */ } // in main: auto fp = GetProcAddress(h, "dllprint"); ?
Feb 15 2014
Don't work DLL module dllmain; import std.c.windows.windows; import core.sys.windows.dll; import core.stdc.stdio; __gshared HINSTANCE g_hInst; export void dllprint() { printf("hello dll world\n"); } extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { final switch (ulReason) { case DLL_PROCESS_ATTACH: g_hInst = hInstance; dll_process_attach( hInstance, true ); break; case DLL_PROCESS_DETACH: dll_process_detach( hInstance, true ); break; case DLL_THREAD_ATTACH: dll_thread_attach( true, true ); break; case DLL_THREAD_DETACH: dll_thread_detach( true, true ); break; } return true; } Main import core.runtime; import std.stdio; import std.container; import std.range; import std.c.windows.windows; alias void function() aaa; aaa bbb; extern (Windows) void main(string[] args) { HMODULE h; FARPROC fp; h = cast(HMODULE) Runtime.loadLibrary("DynamicLib1.dll"); if (h is null) { printf("error loading mydll.dll\n"); } fp = GetProcAddress(h, "dllprint"); //Don't work if (fp is null) { printf("error loading symbol()\n"); } bbb = cast(aaa)fp; bbb(); readln(); }
Feb 15 2014
On Sunday, 16 February 2014 at 07:17:48 UTC, Denis Mezhov wrote:Don't work DLL module dllmain; import std.c.windows.windows; import core.sys.windows.dll; import core.stdc.stdio; __gshared HINSTANCE g_hInst; export void dllprint() { printf("hello dll world\n"); } extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { final switch (ulReason) { case DLL_PROCESS_ATTACH: g_hInst = hInstance; dll_process_attach( hInstance, true ); break; case DLL_PROCESS_DETACH: dll_process_detach( hInstance, true ); break; case DLL_THREAD_ATTACH: dll_thread_attach( true, true ); break; case DLL_THREAD_DETACH: dll_thread_detach( true, true ); break; } return true; } Main import core.runtime; import std.stdio; import std.container; import std.range; import std.c.windows.windows; alias void function() aaa; aaa bbb; extern (Windows) void main(string[] args) { HMODULE h; FARPROC fp; h = cast(HMODULE) Runtime.loadLibrary("DynamicLib1.dll"); if (h is null) { printf("error loading mydll.dll\n"); } fp = GetProcAddress(h, "dllprint"); //Don't work if (fp is null) { printf("error loading symbol()\n"); } bbb = cast(aaa)fp; bbb(); readln(); }Oh, sorry export extern (C) void dllprint() { printf("hello dll world\n"); } It work
Feb 15 2014
On 2/16/2014 4:20 PM, Denis Mezhov wrote:On Sunday, 16 February 2014 at 07:17:48 UTC, Denis Mezhov wrote:I'm curious why you're declaring your main method as extern(Windows).extern (Windows) void main(string[] args) { HMODULE h;
Feb 16 2014