Listing 2: ex1win.cpp, C++ test file on Windows.

// ex1win.cpp  —  Test file for passing a single real 
// argument to a F77 function in a dll
#include <iostream>
#include <windows.h>
int main()
{
    HINSTANCE hDll = LoadLibrary("ex1.dll");
    typedef float (* LPFNDLLFUNC)(float&);
    LPFNDLLFUNC lpFunc = NULL;
    lpFunc = (LPFNDLLFUNC)GetProcAddress(hDll, "foo_");
    float x = 1.2f;
    float y = 0.0f;
    y = lpFunc(x);
    std::cout << "y = foo(" << x << ") = " 
              << y << std::endl;
    FreeLibrary(hDll);
    return 0;
}