www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/04/13/16:26:54

From: calder AT stat DOT colostate DOT edu (Matt Calder)
Subject: RE: Making DLL4s
13 Apr 1997 16:26:54 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <Pine.SUN.3.96.970413152942.8104A-100000.cygnus.gnu-win32@tlaloc.stat.colostate.edu>
Mime-Version: 1.0
X-Authentication-Warning: tlaloc.stat.colostate.edu: calder owned process doing -bs
Original-To: HARBAUGH AT FCRFV1 DOT NCIFCRF DOT GOV
Original-cc: GNU-WIN32 AT cygnus DOT com
In-Reply-To: <970413094623.20411870@FCRFV1.NCIFCRF.GOV>
Original-Sender: owner-gnu-win32 AT cygnus DOT com

	I was very happy to see the original post on trouble
free dll's. I tried it out immediately and was disappointed 
that it did not work for me either. However, a little testing
found that unlike Harbaugh below, I can pass parameters without
errors. My problem is a little more subtle. 
	I am trying to load the dll into an MSVC (2.0) program. 
I find that I can load the dll during the WinMain procedure, and
in some parts of the WinProc (Main window procedure). The library 
will load if I am in the message handler for WM_CREATE or WM_PAINT, 
but not in the message handler for WM_COMMAND! When I say message 
handler I don't mean a separate function just a separate part of
the switch-case logic. That is, my WinProc looks like:

LONG FAR PASCAL WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
	HINSTANCE hInst = NULL;
	DWORD Err=0;
		
    switch (msg){
	case WM_CREATE:
		hInst = LoadLibraryEx("dll.dll", 0, 0);
		Err = GetLastError();
		return 0;
	case WM_PAINT:
	        BeginPaint(hWnd, &ps);
        	EndPaint(hWnd,&ps);
        	return 0;
    	case WM_COMMAND:
		switch (wParam){
		        case IDM_EXIT:
				SendMessage(hWnd, WM_CLOSE,0,0);
	        	        break;
	        	case IDM_LOAD_DLL:
				break;
		}
       		return 0;
	case WM_DESTROY:
        	PostQuitMessage(0);
        	return 0;
	default:
		return (DefWindowProc(hWnd, msg, wParam, lParam));
	 }
}

In this configuration the dll is loaded, if the LoadLibraryEx()
call is moved into the WM_COMMAND portion it will not load. I 
don't understand why, if I use a dll built with MSVC it works 
fine. Any help would be very much appreciated. 

Matt 

On Sun, 13 Apr 1997 HARBAUGH AT FCRFV1 DOT NCIFCRF DOT GOV wrote:

> Subj:	RE: Making DLL4s
> 
> Ismael, your example worked great, but I still have a problem because
> I need to pass arguments.  Whenever I try to write a function that
> passes arguments, the linker complains as follows:
> 

/*****************************************/
/* Matt Calder, Dept. of Statistics, CSU */
/* http://www.stat.colostate.edu/~calder */
/*****************************************/

-
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