The BiAdvPrn.DLL can be linked statically or dynamically.
For a static link, use the BiAdvPrn.lib file. For a dynamic link, load the library with the LoadLibrary() API function and then use the GetProcAddress() API function to load the required functions from the BiAdvPrn.DLL.
/* retrieve a function address from the dll */
BOOL InitDll()
{
HMODULE hDLL;
hDLL = LoadLibrary( DLL_PATH);
if (hDLL)
{
GetOrientation = (_GetOrientation)GetProcAddress(hDLL,szGetOrientation);
if (!GetOrientation)
{
AfxMessageBox(TEXT("Error loading function"),MB_OK,0);
return FALSE;
}
}
/* declare a pointer to the BlackIceDEVMODE structure. The BiLoadPrinterSettings() function will allocate the required amount of memory for the pointer. */
BlackIceDEVMODE* pDevMode;
/* Before using other functions, load the DevMode from the printer with the BiLoadPrinterSettings() function. */
pDevMode = BiLoadPrinterSettings (TEXT(“Black Ice Color”));
if (!pDevMode) {
wsprintf(szMessage, TEXT(
"Error loading the devmode. Error no.: %d ),
BlackIce_GetLastError());
AfxMessageBox(szMessage,MB_OK,0);
return(0);
}
if (!GetOrientation)
{
AfxMessageBox(TEXT("Function not loaded from the DLL"),MB_OK,0);
}
else
{
if( GetOrientation(pDevMode) == 1)
{
// Portrait
}
else
{
if( GetOrientation(pDevMode) == 2)
{
// Landscape
)
else
{
// wrong value;
}
}
}
/* To save the printer settings call BiSavePrinterSettings function. */
bSuccess = BiSavePrinterSettings (TEXT(“Black Ice Color”), pDevMode);
if (!bSuccess)
{
wsprintf(szMessage, TEXT("Error saving the devmode. Error no.: %d"), BlackIce_GetLastError());
AfxMessageBox(szMessage,MB_OK,0);
}
/* At the end you should release the DEVMODE buffer allocated by the BiLoadPrinterSettings () function. You can use the BiReleasePrinterSettings function */
BiReleasePrinterSettings (pDevMode);