Solved

MFC Extension DLLs

Posted on 1998-07-13
6
488 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
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!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 82
Expand macro to ask for filename column 8 37
Hibernate methods 2 83
Sed question 2 122
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

762 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