Solved

MFC Extension DLLs

Posted on 1998-07-13
6
459 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 85
Host to IP 7 73
dog bark java program 15 82
changeXy challenge 13 58
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now