home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip Hitware 7 A
/
CHIP_HITWARE_7A.iso
/
biuro
/
WordWrite
/
_SETUP.1
/
aimdll.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-27
|
5KB
|
148 lines
//----------------------------------------------------------------------------
// AdSoftware System
// Aureate Media Corporation
// Copyright ⌐ 1997-1999. All Rights Reserved.
//
// FILE: aimdll.cpp
// AUTHOR: Mike Olson
//
// OVERVIEW
// ~~~~~~~~
// C++ class to load and control the Aureate Media Advertising DLL
//
//----------------------------------------------------------------------------
#include "aimdll.h"
AimDll::AimDll(long int id, HWND hw, short int ad_size, unsigned long options)
{
// Initialize data members
lastError = 0;
// Load the DLL
hLib = LoadLibrary("advert.dll");
// Locate and bind each function
dllStartup = (bool(__cdecl*)(dll_data*, HINSTANCE, HWND, long program_id, short ad_size, unsigned long options)) GetProcAddress(hLib, "_Startup");
dllPaint = (bool(__cdecl*)(dll_data*, HDC, int, int)) GetProcAddress(hLib, "_Paint");
dllOnClick = (bool(__cdecl*)(dll_data*)) GetProcAddress(hLib, "_OnClick");
dllSetCallback = (bool(__cdecl*)(dll_data*, DllCallbackFunc, void* p)) GetProcAddress(hLib, "_SetCallback");
dllSetAdRecordedCallback = (bool(__cdecl*)(dll_data*, DllCallbackFunc, void* p)) GetProcAddress(hLib, "_SetAdRecordedCallback");
dllSetNetworkCallback = (bool(__cdecl*)(dll_data*, DllCallbackFunc, void* p)) GetProcAddress(hLib, "_SetNetworkCallback");
dllSetBandwidthThrottle = (bool (__cdecl*)(dll_data*, long)) GetProcAddress(hLib, "_SetBandwidthThrottle");
dllSetMinimumAdDisplayTime = (bool (__cdecl*)(dll_data *data, long seconds)) GetProcAddress(hLib, "_SetMinimumAdDisplayTime");
dllIsConnectOkay = (bool (__cdecl*)(dll_data *data, int *okay)) GetProcAddress(hLib, "_IsConnectOkay");
dllRetryConnect = (bool (__cdecl*)(dll_data *data)) GetProcAddress(hLib, "_RetryConnect");
dllSetNetworkState = (bool (__cdecl*)(dll_data *data, bool isNetUp)) GetProcAddress(hLib, "_SetNetworkState");
dllSetProxy = (bool(__cdecl*)(dll_data*, const char* server, long port, const char* additional)) GetProcAddress(hLib, "_SetProxy");
dllGetStatus = (bool (__cdecl*)(dll_data *data, unsigned long* status, bool clear)) GetProcAddress(hLib, "_GetStatus");
dllUseDefaultAd = (bool (__cdecl*)(dll_data *data, const char* image_file, const char* url_file)) GetProcAddress(hLib, "_UseDefaultAd");
dllShutdown = (bool(__cdecl*)(dll_data*)) GetProcAddress(hLib, "_Shutdown");
dllDebugTriggerEvent = (bool(__cdecl*)(dll_data *data, int num)) GetProcAddress(hLib, "_debugTriggerEvent");
// Check to see that the DLL loaded properly and all functions were bound
if ((dllStartup == NULL) || (dllPaint == NULL) || (dllShutdown == NULL) ||
(dllOnClick == NULL) || (dllSetCallback == NULL) ||
(dllSetAdRecordedCallback == NULL) || (dllSetNetworkCallback == NULL) ||
(dllSetBandwidthThrottle == NULL) || (dllSetMinimumAdDisplayTime == NULL) ||
(dllIsConnectOkay == NULL) || (dllRetryConnect == NULL ) ||
(dllSetNetworkState == NULL ) || (dllSetProxy == NULL ) ||
(dllGetStatus == NULL ) || (dllUseDefaultAd == NULL ) ||
(dllDebugTriggerEvent == NULL)) {
FreeLibrary(hLib);
good = false;
lastError = ADE_DLL_LOAD_FAILURE;
} else { // DLL loaded properly, initialize by calling startup
data = new dll_data; // create private data member
data->last_error = &lastError; // set error variable address
good = dllStartup(data, hLib, hw, id, ad_size, options); // initialize the DLL
}
}
AimDll::~AimDll()
{
if (good) {
dllShutdown(data);
FreeLibrary(hLib);
delete data;
}
}
bool AimDll::Paint(HDC dc, int X, int Y)
{
return (good ? dllPaint(data, dc, X, Y) : false);
}
bool AimDll::OnClick(void)
{
return (good ? dllOnClick(data) : false);
}
bool AimDll::SetCallback(DllCallbackFunc f, void* p)
{
return (good ? dllSetCallback(data, f, p) : false);
}
bool AimDll::SetAdRecordedCallback(DllCallbackFunc f, void* p)
{
return (good ? dllSetAdRecordedCallback(data, f, p) : false);
}
bool AimDll::SetNetworkCallback(DllCallbackFunc f, void* p)
{
return (good ? dllSetNetworkCallback(data, f, p) : false);
}
bool AimDll::SetBandwidthThrottle(long BytesPerSec)
{
return (good ? dllSetBandwidthThrottle(data, BytesPerSec) : false);
}
bool AimDll::SetMinimumAdDisplayTime(long seconds)
{
return (good ? dllSetMinimumAdDisplayTime(data, seconds) : false);
}
bool AimDll::IsConnectOkay(bool& okay)
{
if (good) {
int g = 0;
bool ret = dllIsConnectOkay(data, &g);
okay = (bool)g;
return ret;
} else {
return false;
}
}
bool AimDll::RetryConnect(void)
{
return (good ? dllRetryConnect(data) : false);
}
bool AimDll::SetNetworkState(bool isNetUp)
{
return (good ? dllSetNetworkState(data, isNetUp) : false);
}
bool AimDll::SetProxy(const char* server, long port, const char* additional)
{
return (good ? dllSetProxy(data, server, port, additional) : false);
}
bool AimDll::GetStatus(unsigned long& status, bool clear)
{
return (good ? dllGetStatus(data, &status, clear) : false);
}
bool AimDll::UseDefaultAd(const char* image_file, const char* url_file)
{
return (good ? dllUseDefaultAd(data, image_file, url_file) : false);
}
bool AimDll::debugTriggerEvent(int num)
{
return (good ? dllDebugTriggerEvent(data, num) : false);
}