From: ismaelj AT hotmail DOT com (" Ismael Jurado") Subject: Another problem with DLL's 19 Mar 1997 13:35:40 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199703191639.IAA11461.cygnus.gnu-win32@f14.hotmail.com> Content-Type: text/plain X-Originating-IP: [194.179.125.167] Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com I've got a problem with DLL's... Folowing the instruccions of the home page of Cygnus, everything works OK when I link the DLL with my executable but... if you try to load the library indirectly via LoadLibrary(), it returns an HRESULT of 0 Someone knows how to solve this or is just a bug? Thanks, ismaelj AT hotmail DOT com code folows: ---------------------------------------------------------------------- mydll.h ---------------------------------------------------------------------- #include typedef void (*foop)(); void foof(); ---------------------------------------------------------------------- mydll.c ---------------------------------------------------------------------- #include "dll.h" int WINAPI DllMain(HINSTANCE H, DWORD d, PVOID p) { return TRUE; } void WINAPI foof() { MessageBox(NULL, "Hello from the DLL", "DLL", MB_OK); } asm (".section .idata$3\n" ".long 0,0,0,0,0,0,0,0"); ---------------------------------------------------------------------- mydll.def ---------------------------------------------------------------------- EXPORTS foof ---------------------------------------------------------------------- main.c ---------------------------------------------------------------------- #include #include "dll.h" int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow) { HANDLE dllh; foop foo; char buf[126]; dllh=LoadLibrary("mydll.dll"); if ((UINT)dllh <= HINSTANCE_ERROR){ sprintf(buf,"Error loading DLL: %d", dllh); MessageBox(NULL, buf, "APP", MB_OK); } else { foo=(foop)GetProcAddress(dllh, "foof"); if (foo==NULL) MessageBox(NULL, "foo== null", "APP", MB_OK); else foo(); } if ((UINT)dllh > HINSTANCE_ERROR) FreeLibrary(dllh); return 0; } ---------------------------------------------------------------------- Dll link process: ---------------------------------------------------------------------- gcc -c mydll.c ld --dll --subsystem windows -e _DllMain AT 12 -o jnk \ --base-file dll.base mydll.o -L%LIBRARY_PATH% -luser32 dlltool --dllname mydll.dll --base-file dll.base \ --def mydll.def --output-lib mydll.a --output-exp mydll.exp ld --dll --subsystem windows -e _DllMain AT 12 -o mydll.dll \ mydll.exp mydll.o -L%LIBRARY_PATH% -luser32 rm jnk dll.base --------------------------------------------------------- Get Your *Web-Based* Free Email at http://www.hotmail.com --------------------------------------------------------- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".