Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Configuration file in outlook Pin
David Crow7-Jul-04 10:26
David Crow7-Jul-04 10:26 
QuestionScrollbars ?? Pin
0v3rloader7-Jul-04 8:53
0v3rloader7-Jul-04 8:53 
AnswerRe: Scrollbars ?? Pin
Edwin Brunner7-Jul-04 9:18
Edwin Brunner7-Jul-04 9:18 
AnswerRe: Scrollbars ?? Pin
Jesper Knudsen7-Jul-04 10:01
Jesper Knudsen7-Jul-04 10:01 
GeneralRe: Scrollbars ?? Pin
0v3rloader7-Jul-04 11:59
0v3rloader7-Jul-04 11:59 
GeneralRe: Scrollbars ?? Pin
Jesper Knudsen7-Jul-04 12:39
Jesper Knudsen7-Jul-04 12:39 
GeneralRe: Scrollbars ?? Pin
0v3rloader7-Jul-04 14:59
0v3rloader7-Jul-04 14:59 
GeneralOk. More Qs on CDynLinkLibrary and apparent leak. Pin
CherezZaboro7-Jul-04 8:18
CherezZaboro7-Jul-04 8:18 
This article in MSDN
and for example this code in MFC 6 (dllole.cpp) (same in dllnet.cpp) don't connect:

<br />
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)<br />
{<br />
	if (dwReason == DLL_PROCESS_ATTACH)<br />
	{<br />
		// shared initialization<br />
		BOOL bRegister = !extensionDLL.bInitialized;<br />
		AFX_MODULE_STATE* pModuleState = _AfxGetOleModuleState();<br />
		pModuleState->m_hCurrentInstanceHandle = hInstance;<br />
		pModuleState->m_hCurrentResourceHandle = hInstance;<br />
		pModuleState->m_pClassInit = pModuleState->m_classList.GetHead();<br />
		pModuleState->m_pFactoryInit = pModuleState->m_factoryList.GetHead();<br />
		VERIFY(AfxInitExtensionModule(extensionDLL, hInstance));<br />
<br />
		// wire up base DLL class list into private module state<br />
		AfxCoreInitModule();<br />
<br />
		AfxWinInit(hInstance, NULL, _T(""), 0);<br />
<br />
		// Register class factories in context of private module state<br />
		if (bRegister)<br />
			COleObjectFactory::RegisterAll();<br />
<br />
		// restore previously-saved module state<br />
		VERIFY(AfxSetModuleState(AfxGetThreadState()->m_pPrevModuleState) ==<br />
			_AfxGetOleModuleState());<br />
		DEBUG_ONLY(AfxGetThreadState()->m_pPrevModuleState = NULL);<br />
<br />
		// wire up this DLL into the base module state resource chain<br />
		CDynLinkLibrary* pDLL = new CDynLinkLibrary(extensionDLL, TRUE);<br />
		ASSERT(pDLL != NULL);<br />
		pDLL->m_factoryList.m_pHead = NULL;<br />
	}<br />
	else if (dwReason == DLL_PROCESS_DETACH)<br />
	{<br />
		// cleanup module state in base module state<br />
		AfxTermExtensionModule(extensionDLL);<br />
<br />
		// set module state for cleanup<br />
		ASSERT(AfxGetThreadState()->m_pPrevModuleState == NULL);<br />
		AfxGetThreadState()->m_pPrevModuleState =<br />
			AfxSetModuleState(_AfxGetOleModuleState());<br />
<br />
		// cleanup module state in OLE private module state<br />
		AfxTermExtensionModule(extensionDLL, TRUE);<br />
	}<br />
	else if (dwReason == DLL_THREAD_DETACH)<br />
	{<br />
		AfxTermThread(hInstance);<br />
	}<br />
<br />
	return TRUE;    // ok<br />
}<br />
<br />
////////////////////////////////////////////////////////////////////////////<br />
// Special initialization entry point for controls<br />
<br />
void AFXAPI AfxOleInitModule()<br />
{<br />
	ASSERT(AfxGetModuleState() != AfxGetAppModuleState());<br />
<br />
	CDynLinkLibrary* pDLL = new CDynLinkLibrary(extensionDLL, TRUE);<br />
	ASSERT(pDLL != NULL);<br />
	pDLL->m_factoryList.m_pHead = NULL;<br />
}<br />


Because in the article it says that only if a DLL will be used from MFC exe it's OK to put:
<br />
		CDynLinkLibrary* pDLL = new CDynLinkLibrary(extensionDLL, TRUE);<br />

in DLLMain but MFCs code has it anyway which translated into:
<br />
Detected memory leaks!<br />
Dumping objects -><br />
{68} client block at 0x033C4D88, subtype 0, 64 bytes long.<br />
a CDynLinkLibrary object at $033C4D88, 64 bytes long<br />
{64} client block at 0x033C4AA8, subtype 0, 64 bytes long.<br />
a CDynLinkLibrary object at $033C4AA8, 64 bytes long<br />
{57} client block at 0x033C2E18, subtype 0, 64 bytes long.<br />
a CDynLinkLibrary object at $033C2E18, 64 bytes long<br />
Object dump complete.<br />

In my situation.

I do call
<br />
AfxOleInitModule();<br />
AfxNetInitModule();<br />

in my regular DLL as ordered by the article. Now what?
Confused | :confused:
GeneralCheck Boxes Pin
DanYELL7-Jul-04 8:15
DanYELL7-Jul-04 8:15 
GeneralRe: Check Boxes Pin
Ravi Bhavnani7-Jul-04 8:28
professionalRavi Bhavnani7-Jul-04 8:28 
Generalthread (?) question Pin
sandrineV7-Jul-04 7:53
sandrineV7-Jul-04 7:53 
GeneralRe: thread (?) question Pin
palbano7-Jul-04 9:30
palbano7-Jul-04 9:30 
GeneralRe: thread (?) question Pin
sandrineV8-Jul-04 2:55
sandrineV8-Jul-04 2:55 
QuestionMaximaze window ??? Pin
Larsson7-Jul-04 6:41
Larsson7-Jul-04 6:41 
AnswerRe: Maximaze window ??? Pin
jmkhael7-Jul-04 6:44
jmkhael7-Jul-04 6:44 
GeneralRe: Maximaze window ??? Pin
Larsson7-Jul-04 7:04
Larsson7-Jul-04 7:04 
GeneralRe: Maximaze window ??? Pin
jmkhael7-Jul-04 7:08
jmkhael7-Jul-04 7:08 
Generaluser mapping of shortcut keys Pin
John R. Shaw7-Jul-04 6:38
John R. Shaw7-Jul-04 6:38 
GeneralRe: user mapping of shortcut keys Pin
DavidR_r7-Jul-04 8:49
DavidR_r7-Jul-04 8:49 
GeneralRe: user mapping of shortcut keys Pin
John R. Shaw7-Jul-04 9:47
John R. Shaw7-Jul-04 9:47 
GeneralChging default printers Pin
Jim Barrett7-Jul-04 6:28
Jim Barrett7-Jul-04 6:28 
Generalsubclassing in win32 Pin
Manu817-Jul-04 6:14
Manu817-Jul-04 6:14 
GeneralRe: subclassing in win32 Pin
Antti Keskinen7-Jul-04 10:54
Antti Keskinen7-Jul-04 10:54 
GeneralHooK API Problem Pin
cyberkit7-Jul-04 5:19
cyberkit7-Jul-04 5:19 
GeneralHyper-threading and MSDev6 Pin
[d3m0n]7-Jul-04 4:55
[d3m0n]7-Jul-04 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.