|
Joao Vaz wrote:
a book called MFC Internals
Hmm, i'll check it out. Thanks again!
--------
And we die young.
Faster we run. Alice in Chains, We Die Young
|
|
|
|
|
You wouldn't regret it !!!!
Cheers,
Joao Vaz
The Most Unhappy and Frustrated TCL programmer,besides that a Happy guy
|
|
|
|
|
is there no simple way to delete a registry key? i have been looking and it seems it takes 20 lines of code just to delete a key..
i use :
WriteProfileString("Settings", "name", strName);
to store it, is it really that hard to remove it?
thanks for your advice!
-dz
|
|
|
|
|
LONG RegDeleteKey(
HKEY hKey, // handle to open key
LPCTSTR lpSubKey // subkey name
);
That's the function I use!
Al
|
|
|
|
|
well part of the problem is that i dont know the HKEY, the WriteProfileString() function takes different values, and I'm not sure how to find out what the HKEY is, is there a command to get it somehow?
thanks for the responce!
-dz
|
|
|
|
|
You could open the registry with:
LONG RegOpenKeyEx(
HKEY hKey, // handle to open key
LPCTSTR lpSubKey, // subkey name
DWORD ulOptions, // reserved
REGSAM samDesired, // security access mask
PHKEY phkResult // handle to open key
);
And the delete it with:
DWORD SHDeleteKey(
HKEY hkey,
LPCTSTR pszSubKey
);
Or:
LONG DelRegTree(
HKEY hParentKey,
const CString& strKeyName
);
However yoiu need the HKEY you can open it to get the HKEY with the SubKey from WriteProfileString()
Oh! Are you asking in MC++? You see I don't know if this question is for MC++ or C++ because we don't have a MC++ forum ... yet
So if you are using MC++ remember to
[DllImport("user32.dll")]
Joke a part, hope this help. That's all I know about the registry, somebody else may be able to help
|
|
|
|
|
I guess you refer to the inability of RegDeleteKey to delete keys recursively in NT/2000/XP (the same function recursively deletes keys in 95/98/ME). The function <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/Shell/reference/shlwapi/registry/shdeletekey.asp">SHDeleteKey</a> , on the other hand, deletes keys in a recursive manner for both families of OSs --and it's only one line of code.
Caveat: SHDeleteKey is not present in 95 and NT 4.0 systems without IE 4.0 or higher. It is provided by default in later OSs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I must not be phrasing something right.. i have a variable in the registry 'key' under the following path:
HKEY_CURRENT_USER/Software/DeveloperName/Program/Settings/
the value is called 'UserName' and it is set to a string
to set this value i call:
WriteProfileString("Settings", "UserName", "Fred Smith");
I cannot figure out how to use the RegDeleteKey() function because it takes an HKEY variable type, how do i find out this value? i have tried passing the path and the value to delete, but that doesnt work..
hope that clarifies?
-dz
|
|
|
|
|
HKEY myKey;
LONG RegOpenKeyEx(HKEY_CURRENT_USER,
"/Software/DeveloperName/Program/Settings/",
0,
0,
&myKey);
And the delete it with:
DWORD SHDeleteKey(HKEY myKey,
"/Software/DeveloperName/Program/Settings/"
);
To delete a value is something like:
LONG RegDeleteValue(
myKey, // handle to key
LPCTSTR lpValueName // value name
);
Hope this helps!
Al
|
|
|
|
|
I must not be phrasing something right
Yep, I misundesrstood your question. sorry. If I got it now, the way to delete a given key is by calling RegDeleteKey like this:
::RegDeleteKey(
HKEY_CURRENT_USER,
CString(AfxGetApp()->m_pszRegistryKey)+"\\"+AfxGetApp()->m_pszProfileName+"\\Settings\\UserName"); (Sort of, I haven't tested it.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried your solution, as well as Pascal's, neither give any errors, but neither delete the key.. i traced the string before calling the RegDeleteKey() and the path looks exactly as it does in regedit, but the key never gets deleted..
-dz
|
|
|
|
|
!! I don't have any compiler handy, but I'll give this a try tomorrow morning (CET) and tell you back (in case you haven't found the solution yet.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This is the shortest solution I found (it really works, I tried it):
HKEY hKey=NULL;
::RegOpenKeyEx(
HKEY_CURRENT_USER,
CString("Software\\")+AfxGetApp()->m_pszRegistryKey+"\\"+AfxGetApp()->m_pszProfileName+"\\Settings",
0,KEY_WRITE,&hKey);
::RegDeleteValue(hKey,"name");
::RegCloseKey(hKey);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks a bunch
-dz
|
|
|
|
|
hi every body
i added a microsoft ado data control after that many classes added to my workspace such as C_Recordset.., i need any help or example to know how connect and make a query.
Best Regards
|
|
|
|
|
They are lot of articles in CP. Maybe you can find it there.
http://www.codeproject.com/database/
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Also look in MSDN, you will find some good examples there too
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Help me please, how transfering the info between two Property Pages, inserting into the Property Sheet?
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
There's no standard way to do that as far as I know, so you can just use your imagination Off the top of my hat, one method is as follows. Derive CMyPropertySheet from CPropertySheet and add member variables to hold the common data. When exiting a property page, store the relevant data into the parent:
BOOL COnePropertyPage::OnKillActive()
{
if(!CPropertyPage::OnKillActive())return FALSE;
static_cast<CMyPropertySheet*>(GetParent())->m_commonData=...;
return TRUE;
} and retrieve in the other property pages at OnSetActive , you get the idea.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
As the variant, it approaches me!
Thank for the help
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Besides the method provided by Joaquín M López Muñoz, I have a way to do it.
Since propertypage is in fact a dialog, when you add them to your propertysheet, you have an object of each page already. say:
CPageD1 m_d1;
CPageD2 m_d2;
CPropertySheet m_sheet;
....
m_sheet.AddPage(&m_d1);
m_sheet.AddPage(&m_d2);
....
m_d1.m_data1 = m_d2.m_data2;
Can't you do this?
|
|
|
|
|
This variant suits at a stage of addition PropertyPage to PropertySheet, and it is necessary for me transfer at work in PropertyPage
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
If you have the Academic version of VS.NET... do you know what they mean that I have to activate the licence? ?
Where can I activate it then!?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
You need to activate it if you want to run it more than 4 times. Once you activate it on a machine, that particular CD is locked to your machine. You cant activate another version from a different machine.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
How do I activate it then!?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|