/*!
* \brief mIRC DLL Load Function
*
* This function is called when the DLL is loaded.
*
* It initializes all what the DLL needs and links mIRC received information to the mIRCDLL \b mIRCLink
* data structure to be used later in various functions in the DLL.
*
* \param load mIRC Load Structure Pointer
*/
void WINAPI LoadDll( LOADINFO * load ) {
mIRCLink.m_hFileMap = CreateFileMapping( INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 4096, "mIRC" );
mIRCLink.m_pData = (LPSTR) MapViewOfFile( mIRCLink.m_hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, 0 );
mIRCLink.m_mIRCHWND = load->mHwnd;
g_OldmIRCWindowProc = (WNDPROC) SetWindowLong( mIRCLink.m_mIRCHWND, GWL_WNDPROC, (LONG) mIRCSubClassWinProc );
WNDCLASS wc;
ZeroMemory( &wc, sizeof( WNDCLASS ) );
wc.hInstance = GetModuleHandle( NULL );
wc.lpszClassName = XPOPUPMENUCLASS;
wc.lpfnWndProc = XPopupMenu::XPopupWinProc;
RegisterClass( &wc );
mhMenuOwner = CreateWindow( XPOPUPMENUCLASS, NULL, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(NULL), 0 );
g_mIRCPopupMenu = new XPopupMenu( NULL );
g_mIRCMenuBar = new XPopupMenu( GetMenu( mIRCLink.m_mIRCHWND ) );
}
/*!
* \brief mIRC DLL UnLoad Function
*
* This function is called when the DLL is unloaded.
*
* It initializes all what the DLL needs and links mIRC received information to the mIRCDLL \b mIRCLink
* data structure to be used later in various functions in the DLL.
*
* \param timeout Unload trigger indicator (0 = timeout unload after 10 min - 1 = exit or /dll -u)
*/
int WINAPI UnloadDll( int timeout ) {
// DLL unloaded because mIRC exits or /dll -u used
if ( timeout == 0 ) {
SetWindowLong( mIRCLink.m_mIRCHWND, GWL_WNDPROC, (LONG) g_OldmIRCWindowProc );
g_XPopupMenuManager.clearMenus( );
delete g_mIRCPopupMenu;
g_mIRCMenuBar->cleanMenu( GetMenu( mIRCLink.m_mIRCHWND ) );
delete g_mIRCMenuBar;
if ( mhMenuOwner != NULL )
DestroyWindow( mhMenuOwner );
UnregisterClass( XPOPUPMENUCLASS, GetModuleHandle( NULL ) );
UnmapViewOfFile( mIRCLink.m_pData );
CloseHandle( mIRCLink.m_hFileMap );
return 1;
}
// keep DLL in memory
else
return 0;
}
/*!
* \brief blah
*
* blah
*/