Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MFC Extension DLLs

Posted on 1998-07-13
6
Medium Priority
?
524 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 200 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

664 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