🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #2489

DLL problem (using BC++/AF)

#2489
From: Ahmad Alavi
Date: Tue, 05 Jan 1993 21:20
56 lines
2117 bytes
I have problem calling a routine in a DLL when the DLL is loaded
using LoadLibrary.

Here is the DLL source code in its entirely.

    #include <windows.h>
    int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
                                   WORD wHeapSize, LPSTR lpszCmdLine )
    {
        if ( wHeapSize != 0 )
	        UnlockData( 0 );
        return 1;
    }

    BOOL FAR PASCAL MyFunction (char far *theString) /* this functions is */
    {                                            /* exported in .DEF */
         return 1;
    }


And the main executable source:

    #include <owl.h>
    int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine, int nCmdShow)
    {
        HINSTANCE DLLInstance;
        BOOL FAR (*MyFunctionFunc)(char far  *theString);
        DLLInstance = LoadLibrary("dll1.dll");
        (FARPROC) MyFunctionFunc =GetProcAddress(DLLInstance, "MyFunction");
        (*MyFunctionFunc)("In the MAIN");
        FreeLibrary(DLLInstance);

        TApplication MyApp("Sample Program", hInstance, hPrevInstance,
               lpCmdLine, nCmdShow);
        MyApp.Run();
        return MyApp.Status;
    }

When I run the main program, everything looks OK and MyFunction in DLL
is actually called but I get a General Protection Fault. The error happens
inside MyApp.Run() call. If I change MyFunction argument to int the
there is no problem (but I really need it to be char*).

I have a short term and long term question.

STQ: What is wrong with the above programs?
LTQ: What is a good refrence book for DLL programming?

Post or mail.

Thanks.

Ahmad
ahmad@norooz.b17a.ingr.com
Technical Details
Message-ID: <1993Jan5.212008.6162@msdhsv.ingr.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!msdhsv!norooz!ahmad

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!msdhsv!norooz!ahmad
From: ahmad@norooz.NoSubdomain.NoDomain (Ahmad Alavi)
Subject: DLL problem (using BC++/AF)
Message-ID: <1993Jan5.212008.6162@msdhsv.ingr.com>
Sender: usenet@msdhsv.ingr.com (USENET)
Reply-To: ahmad@norooz.b17a.ingr.com
Organization: " "
Date: Tue, 5 Jan 1993 21:20:08 GMT
Lines: 57