#if defined(_MSC_VER)
#include <windows.h>
#else
#include <pharlap.h>
#include <dosx32.h>
#endif

unsigned print_file(char *type, char *filename)
{
    char dll_name[9];
    typedef unsigned (*PROC)(LPTSTR);
    HINSTANCE dll_handle;
    PROC Print;
    unsigned ret;

    strcpy(dll_name, "PRINT_");
    strcat(dll_name, type);         /* assemble PRINT_XX name */
printf("calling LoadLibrary\n");
    dll_handle = LoadLibrary(dll_name);
printf("returned from LoadLibrary\n");
    if (dll_handle == NULL)
        return FALSE;               /* couldn't load PRINT_XX.DLL */
printf("calling GetProcAddress\n");
    Print = (PROC) GetProcAddress(dll_handle, "Print");
printf("returned from GetProcAddress\n");
    if (Print == NULL)
        return FALSE;               /* couldn't find Print() function */
    ret = (Print)(filename);       /* call through function pointer */
    FreeLibrary(dll_handle);
    return ret;
}


void main ()
{
    char * filename;
    char type[2];
    int i;

    printf("Enter two letter printer type:\n");
    printf("PS for PostScript\n");
    printf("FX for Epson FX Series\n");
    gets(type);
    for (i=0; i<strlen(type); i++)
        type[i] = toupper(type[i]);
    if ((!strcmp(type,"PS") ) && (!strcmp(type,"FX")) )
    {
        printf("Invalid Printer Specification\n");
        exit(1);
    }
    if (!print_file(type, "Hello.world"))
        printf("error printing\n");
    exit(0);
}
