Solved

registery

Posted on 1998-01-09
2
215 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

19 Experts available now in Live!

Get 1:1 Help Now