public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: " Ismael  Jurado" <ismaelj@hotmail.com>
To: gnu-win32@cygnus.com
Subject: Another problem with DLL's
Date: Wed, 19 Mar 1997 10:28:00 -0000	[thread overview]
Message-ID: <199703191639.IAA11461@f14.hotmail.com> (raw)

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@hotmail.com


code folows:
----------------------------------------------------------------------
mydll.h
----------------------------------------------------------------------
#include <windows.h>

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 <stdio.h>
#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@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@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@cygnus.com" with one line of text: "help".

             reply	other threads:[~1997-03-19 10:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-19 10:28  Ismael  Jurado [this message]
1997-03-20 11:37 John Cerney
1997-03-21  6:04 Valery Fine
1997-03-21  6:04 ` John Cerney
1997-03-21 11:43  Ismael  Jurado
1997-03-22  0:39 Sergey Okhapkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199703191639.IAA11461@f14.hotmail.com \
    --to=ismaelj@hotmail.com \
    --cc=gnu-win32@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).