Solved

MFC Extension DLLs

Posted on 1998-07-13
6
497 Views
Last Modified: 2013-11-20
Hello,

I created an MFC Extension DLL, and in my MFC application I access this extension dll.  The problem that I ran into is I cannot access my MFC application's registry information.  Is there anyway to get access to CWinApp from my extension dll (i.e., AfxGetApp() -> GetProfileString().)

Thanks,
Jennifer
0
Comment
Question by:jli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 50 total points
ID: 1319095
MFC extension DLL doesn't have its own CWinApp class instance but uses one of application that has loaded it. MFC extension DLL can be used only by MFC EXE. You can use AfxGetApp() function from an extension DLL, you will get pointer to EXE global instance of CWinApp class
0
 

Author Comment

by:jli
ID: 1319096
I am using MFC EXE to load this extension DLL.  However, when I try to call AfxGetApp() -> GetProfileString() in my extension DLL, I get a access violation because the m_pszRegistryKey contains a empty string in appui3.cpp. I tried including _AFXDLL in my MFC EXE project, but when I compile my MFC EXE I get an error saying I need to use /MD switch. I tried to include this switch, but I still get errors. I am not sure what I am doing incorrectly.

Thanks,
Jennifer
0
 
LVL 7

Expert Comment

by:galkin
ID: 1319097
Your problem is that you didn't allocated and set CWinApp::m_pszProfileName in InitInstance
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jli
ID: 1319098
I am not sure if I understand. I set the registry key SetRegistryKey() in my MFC EXE InitInstance(). Why do I need to set CWinApp::m_pszProfileName when I am using the registry and not ini file?

Thanks,
Jennifer
0
 
LVL 7

Expert Comment

by:galkin
ID: 1319099
First I don't understand if you are tryingto read from registry or INI file. SetRegistryKey() redirects profile settings from INI file to registry. So Get(Set)ProfileString(Int) read/write from registry instead of INI file. Check that when you call SetRegistryKey() m_pszProfileName is set to correct data. Also check that when you call AfxGetApp() you get pointer to EXE CWinApp object instance
0
 

Author Comment

by:jli
ID: 1319100
Yes, I am trying to read from my MFC EXE application's registry settings. I will try to step into the extension DLL to see if I am getting the same CWinApp as my MFC EXE. I will let you know.

Thanks,
Jennifer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question