Solved

registery

Posted on 1998-01-09
2
237 Views
Last Modified: 2013-11-20
when we use setregisterkey("myplace");
we get a place under HKEY_CURRENT_USER, Software,
myplace, "app title".

question 1, can I make the last dir "app title"  any arbitrary text
without changing the actual app.title. ?

question 2, this is under current user, so what if some other user
logs in and want to access this  same information ?
How to write to  a common place for the machine for all users ?

0
Comment
Question by:hasmet
  • 2
2 Comments
 
LVL 2

Accepted Solution

by:
anichini earned 50 total points
ID: 1313675
1) use CWinApp:m_pszProfileName - be sure to put this code AFTER the call to SetRegistryKey:

//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszProfileName);
//Change the name of the .INI file.
//The CWinApp destructor will free the memory.
m_pszProfileName=_tcsdup(_T("d:\\somedir\\myini.ini"));

Note   If you assign a value to m_pszProfileName, it must be dynamically allocated on the heap. The CWinApp destructor calls free( ) with this pointer. You many want to use the _tcsdup( ) run-time library function to do the allocating. Also, free the memory associated with the current pointer before assigning a new value. For example:

2) You want to put stuff that's common to all users in HKEY_LOCAL_MACHINE/Software/yourplace/profile. Unfortunately, MFC doesn't have any handy utility routines for accomplishing this, so you have to use the API registry functions - look in the SDK docs for RegOpenKeyEx and it's companions.



0
 
LVL 2

Expert Comment

by:anichini
ID: 1313676
Oh, and I realize the code says "change the name of the INI file" but trust me, it'll affect the registry key!

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 63
canBalance challenge 34 80
Use of condition with 'serial' in ansible 2 58
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 249
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
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…

786 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