// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>

using namespace std;

#include <windows.h>

typedef void (*VF)();

static VF realf;

extern "C"
{
BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved);
__declspec(dllexport) void f();
}

BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    if(ul_reason_for_call == DLL_PROCESS_ATTACH)
    {
        cout << "driver DlLMain says hi from C++" << endl;
        HINSTANCE glue = LoadLibrary("glue.dll");
        realf = (VF)GetProcAddress(glue, "f");
    }
    return TRUE;
}

__declspec(dllexport) void f()
{
    cout << "driver f says hi from C++" << endl;
    realf();
}
