delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/02/24/20:31:09

From: vischne AT ibm DOT net
Subject: Exporting functions from .exe modules?
24 Feb 1998 20:31:09 -0800 :
Message-ID: <199802241410.OAA141632.cygnus.gnu-win32@out2.ibm.net>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Just how does one export a function from an executable module using
GNU?  There are procedures for marking DLLs using dlltool, but can
you mark an .exe file similarly?  The following program ought to work
when the program ExportLib.exe is compiled using a non-GNU compiler
with the `_export' keyword in the header of each of the exported
functions.


#include <windows.h>

int main (int argc, char **argv)
{
  void (*libcall) (void);
  HINSTANCE libhandle;
  int index;
  char cmdbuf[256];
	libhandle = LoadLibrary("ExportLib.exe");
	printf("libhandle = %d\n", (unsigned)libhandle);
	for (index = 1 ; index <= 3 ; index++)
	 {
	  sprintf(cmdbuf, "export%d", index);
	  libcall = GetProcAddress(libhandle, cmdbuf);
	  printf("Calling export%d with address %p\n", index, (void *)libcall);
	  if ((FARPROC)libcall != (FARPROC)NULL) libcall();
	 };
	FreeLibrary(libhandle);
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019