A
AroDeep
Guest
LoadLibrary nullify the mainframe object. This code works fine in VS2010.
#if !defined(AFX_SIRRETVALUE_H__EF8A65E0_26FD_11D7_BA6A_4000040D08A6__INCLUDED_)
#define AFX_SIRRETVALUE_H__EF8A65E0_26FD_11D7_BA6A_4000040D08A6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
class CSIRRETVALUEApp : public CWinApp
{
public:
CSIRRETVALUEApp();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_SIRRETVALUE_H__EF8A65E0_26FD_11D7_BA6A_4000040D08A6__INCLUDED_)
***************************************************************************************************************************************************************
//DLL Code
//DLL Code
#include "stdafx.h"
#include "SiRValue.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CSIRRETVALUEApp, CWinApp)
//{{AFX_MSG_MAP(CSiRValueApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CSIRRETVALUEApp::CSIRRETVALUEApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
CSIRRETVALUEApp theApp;
extern "C" __declspec( dllexport )
String *FireRule( CObList& list )
{
AFX_MAINTAIN_STATE2 *pState = new AFX_MAINTAIN_STATE2(AfxGetStaticModuleState());
return (CString*)"Test";
} // End of FireRule function
***************************************************************************************************************************************************************************************
//Calling code (MFC program)
ConvFrameWnd* pFrame1 = (ConvFrameWnd*)AfxGetApp()->m_pMainWnd;
HINSTANCE hModule;
hModule = LoadLibrary("SiRValue.Dll");
ConvFrameWnd* pFrame = (ConvFrameWnd*)AfxGetApp()->m_pMainWnd;
In the calling(mfc)program , pFrame1 is initialized correctly.hModule is also showing me value(not null). But pFRame object is null just after loadlibrary. I am not able to understand the reasaon , why pFrame is null.
Continue reading...
#if !defined(AFX_SIRRETVALUE_H__EF8A65E0_26FD_11D7_BA6A_4000040D08A6__INCLUDED_)
#define AFX_SIRRETVALUE_H__EF8A65E0_26FD_11D7_BA6A_4000040D08A6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
class CSIRRETVALUEApp : public CWinApp
{
public:
CSIRRETVALUEApp();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_SIRRETVALUE_H__EF8A65E0_26FD_11D7_BA6A_4000040D08A6__INCLUDED_)
***************************************************************************************************************************************************************
//DLL Code
//DLL Code
#include "stdafx.h"
#include "SiRValue.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CSIRRETVALUEApp, CWinApp)
//{{AFX_MSG_MAP(CSiRValueApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CSIRRETVALUEApp::CSIRRETVALUEApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
CSIRRETVALUEApp theApp;
extern "C" __declspec( dllexport )
String *FireRule( CObList& list )
{
AFX_MAINTAIN_STATE2 *pState = new AFX_MAINTAIN_STATE2(AfxGetStaticModuleState());
return (CString*)"Test";
} // End of FireRule function
***************************************************************************************************************************************************************************************
//Calling code (MFC program)
ConvFrameWnd* pFrame1 = (ConvFrameWnd*)AfxGetApp()->m_pMainWnd;
HINSTANCE hModule;
hModule = LoadLibrary("SiRValue.Dll");
ConvFrameWnd* pFrame = (ConvFrameWnd*)AfxGetApp()->m_pMainWnd;
In the calling(mfc)program , pFrame1 is initialized correctly.hModule is also showing me value(not null). But pFRame object is null just after loadlibrary. I am not able to understand the reasaon , why pFrame is null.
Continue reading...