Solved

MFC Extension DLLs

Posted on 1998-07-13
6
483 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.

856 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