|
Okey. CRegKey is easier than SDK methods. If any help, feel free to ask.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Yes. Totally right.
I just discovered that CRegKey is a wrapper around the SDK methods which allows easier usage / less coding work.
(We all love that .. don't we )
So using the SDK functions directly wouldn't be smart.
I already managed to deleted/create a new key at the 'HKEY_LOCAL_MACHINE' so that's cool.
But i miss 1 big feature (maybe you can still help me with this one).
Let's say i want to copy all contents (all keys and all values of it subkeys) of 'HKEY_CURRENT_USER\Software\CompanyName\ProgName\'
to 'HKEY_LOCAL_MACHINE\Software\CompanyName\ProgName\'
So it's an entire "copy" that has to be made + sub keys should be copied too.
How can i achieve this? I'd like to combine this with the CRegKey class anyways.
Greetings
Jens
|
|
|
|
|
I think there is no readymade function to copy the regkeys recursively.
Using the RegEnumKey () or RegEnumKeyEx () function, we get all the subkeys under a specific key.
Then using this function you can recursively traverse the registry subtree. For that you should know the tree traversal algorithm. Then while reading each key, make an identical copy of it under the destination keytree.
Hope this helps you. The only problem is the tree traversal. It will be a little bit difficult. Dont worry. Im searching some more easier method for copying the registry and will inform you, when i get it.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
ehehe allrightie then
Let me know when you have found something usefull
Thanks
Jens
|
|
|
|
|
hai Jens,
Use the following code. I got it from my friend - John AV, who is a registry expert. Okey. First be thorough with the code, make any changes if you need, then use it.
const static int nMaxValueNameSize = MAX_PATH;
const static int nMaxValueValueSize = 4096;
const static int nMaxClassSize = MAX_PATH;
const static int nMaxKeyNameSize = MAX_PATH;
BOOL CopyRegistryKey(HKEY hkRootFrom, const CString& strFromPath, HKEY hkRootTo, const CString& strToPath)
{
HKEY hkFrom;
LONG res = ::RegOpenKeyEx(hkRootFrom, strFromPath, 0, KEY_READ, &hkFrom);
if (ERROR_SUCCESS != res) {
return FALSE;
}
HKEY hkTo;
res = ::RegCreateKeyEx(hkRootTo, strToPath, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hkTo, 0);
if (ERROR_SUCCESS != res) {
::RegCloseKey(hkFrom);
return FALSE;
}
BOOL bRes = CopyKeys(hkFrom, hkTo) && CopyValues(hkFrom, hkTo);
::RegCloseKey(hkFrom);
::RegCloseKey(hkTo);
return bRes;
}
static BOOL CopyKeys(HKEY hkFrom, HKEY hkTo)
{
TCHAR lpstrName[nMaxKeyNameSize];
TCHAR lpstrClass[nMaxClassSize];
for (int i = 0;;i++) {
DWORD nNameSize = nMaxKeyNameSize;
DWORD nClassSize = nMaxClassSize;
LONG res = ::RegEnumKeyEx(hkFrom, i, lpstrName, &nNameSize, 0, lpstrClass, &nClassSize, 0);
if (ERROR_NO_MORE_ITEMS == res) {
break;
}
HKEY hkNew;
res = ::RegCreateKeyEx(hkTo, lpstrName, 0, lpstrClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hkNew, 0); ;
if (ERROR_SUCCESS != res) {
return FALSE;
}
::RegCloseKey(hkNew);
BOOL bRes = CopyRegistryKey(hkFrom, lpstrName, hkTo, lpstrName);
if (! bRes) {
return FALSE;
}
}
return TRUE;
}
static BOOL CopyValues(HKEY hkFrom, HKEY hkTo)
{
TCHAR lpstrName[nMaxValueNameSize];
BYTE pValue[nMaxValueValueSize];
for (int i = 0;;i++) {
DWORD nType;
DWORD nNameSize = nMaxValueNameSize;
DWORD nValueSize = nMaxValueValueSize;
LONG res = ::RegEnumValue(hkFrom, i, lpstrName, &nNameSize, 0, &nType, pValue, &nValueSize);
if (ERROR_NO_MORE_ITEMS == res) {
break;
}
res = ::RegSetValueEx(hkTo, lpstrName, 0, nType, pValue, nValueSize);
if (ERROR_SUCCESS != res) {
return FALSE;
}
}
return TRUE;
}
Hope this helped you.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Hi all,
Is there any way by which we can spy on the actual HTML being sent to the Browser Window.
Irrespective of the Browser we are using !
Do i have to write some driver to actually filter the HTML content ?
And it should be installed seamlessly (without having to set Ports manually)
Any suggestions will do
but please reply
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
For this you will have to run your code on the event a port opened in local and connected to remote 80 . Remote port may be different if http port for that server is different eg:when ssl is installed.
However i dont feel there is any such event in windows.
Also may be you can try to run a netstat like application and moniter all the current connection and do wot you want. But this has the disadvantage that its like a polling mechanism.
greatest thing is to do wot others think you cant suhredayan@omniquad.com
|
|
|
|
|
i want something of this sort
http://www.codeproject.com/tools/htmlfilter.asp[^]
But it requires change to the proxy settings of browser window
can that be done automatically ?
Any suggestions ?
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
|
No NO Brother No BHO's
must work on other browsers as well
thanks for replying anyway
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Hi All,
I want to write an application which will display all the running processes of a remote machine. Any idea how to do this ?
Thanks,
Mahesh Varma.
|
|
|
|
|
Hi,
what problem in this code.
//function call
m_hThread1 =(HANDLE)_beginthreadex (NULL,0,RequestProcess1,NULL,0,&m_dwThreadId1);
/fucntion
unsigned __stdcall CIFakerDlg::RequestProcess1(void *dummmy)
{
statements
}
i got the following error
error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int (void *)' to 'unsigned int (__stdcall *)(void *)'
None of the functions with this name in scope match the target type
any one help tome. thanks in advance.
Murali.M
|
|
|
|
|
Make the RequestProcess1 as static function. Refer the SDK.
The _beginthread is declared as
unsigned long _beginthread( void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist );
Mahesh
|
|
|
|
|
I have created an activeX control, in which i added a property page whom based class is COlePropertyPage. Everything is all right. In the next step, i want to show my property page as a simple CDialog. As the based class of the COlePropertyPage class is CDialog, i thought to write the following :
CMyPropPage dlgProp;<br />
dlgProp.DoModal();
But it didn't go well.
Could you please help me.
|
|
|
|
|
Without seeing any code it's impossible to answer.
Are you using the right thread ID? Does the thread have a message queue? Are you processing messages from the queue?
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
You cannot truly appreciate Dilbert unless you've read it in the original Klingon.
|
|
|
|
|
Do you use the ON_THREAD_MESSAGE macro with the right parameters and handlers?
Try this @ home. (B&B)
|
|
|
|
|
Can I retrieve a pointer to the listbox of a combobox in CBS_DROPDOWNLIST style?
I'd like to change the dropped rect, but unfortunately there is no SetDroppedRect().
Toon
|
|
|
|
|
If you want to change the size of the listbox when we click the dropdown button of the combobox at design time, the solution is below.
1. First doubleclick the dialog from the resource view.
2. Then select your combo box.
3. Now click on the dropdown button on the combobox.
4. Then resize the selection (drag baseline of the selction rectangle) and that will be the size of the listbox.
isn't it simple?
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
You can change the width and height of the dropdown listbox with following two functions in CComboBox.
to change the dropdown list width
to the longest string in the combobox
<br />
extern CComboBox* pmyComboBox;<br />
<br />
CString str;<br />
CSize sz;<br />
int dx=0;<br />
CDC* pDC = pmyComboBox->GetDC();<br />
for (int i=0;i < pmyComboBox->GetCount();i++)<br />
{<br />
pmyComboBox->GetLBText( i, str );<br />
sz = pDC->GetTextExtent(str);<br />
<br />
if (sz.cx > dx)<br />
dx = sz.cx;<br />
}<br />
pmyComboBox->ReleaseDC(pDC);<br />
<br />
dx += ::GetSystemMetrics(SM_CXVSCROLL) + 2*::GetSystemMetrics(SM_CXEDGE);<br />
<br />
pmyComboBox->SetDroppedWidth(dx);<br />
Change the each item height of dropdown list to 50px
<br />
extern CComboBox* pmyComboBox;<br />
<br />
CString str;<br />
CSize sz;<br />
int dx=0;<br />
CDC* pDC = pmyComboBox->GetDC();<br />
for (int i=0;i < pmyComboBox->GetCount();i++)<br />
{<br />
pmyComboBox->SetItemHeight( i, 50 );<br />
}<br />
pmyComboBox->ReleaseDC(pDC);<br />
<br />
<br />
greatest thing is to do wot others think you cant suhredayan@omniquad.com
|
|
|
|
|
Thx a lot for helping.
But what heppens when the strings are so long the can't be fully displayed and the horizontal scrollbar needs to be shown?
Answer : in case of 1 item there is an invisible scrollbar,
in case of 2 items, the scrollbar covers the second item
in case of more items, it looks nice and correct.
In the first two cases the solution with a horizontal scrollbar does not look nice, so I thought to resize the listbox in height but you cannot because c++ itself does resize the listbox to the number of items in the list without taking the size of a horizontal listbox into account.
Can I prohibbit this automatic sizing?
and again, Thx for helping
Toon Schellinck
|
|
|
|
|
Hi.
I try to create an ActiveX control (VC 6.0 FullControl) and i want to control size of my ActiveX control both in design mode and run time,to do it i override
IOleObjectImpl::SetExtent(...) method .But when i draw my control in design time (in resource editor) it have one size (SIZE* psizel param)but when i execute my application in run time it has another size.Please help.
Tanks.
|
|
|
|
|
Hi
I would like to know how to make a toolbar button toggle. For example, in MDI if there are two child windows and corresponding buttons on the toolbar for them, if the button is clicked once then the child window should appear and when it is clicked for the second time the child window should dissappear. Please help me regarding this. This is urgent.
Thanking you,
Regards
Ruchit Sharma. R
|
|
|
|
|
|
hi,
what problem in the following code. when i select new folder i got error. application is closed. i test i release mode. any one help to me.
CString m_strFolderPath;
LPMALLOC pMalloc = NULL;
LPITEMIDLIST pidl = NULL;
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(BROWSEINFO));
// set the bi's default values
bi.hwndOwner = m_hWnd;
bi.lpszTitle = _T("Current folder is:");
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
//bi.lpfn = BrowseCallbackProc;
pidl = SHBrowseForFolder(&bi);
if(pidl != NULL)
{
SHGetPathFromIDList(pidl,
m_strFolderPath.GetBuffer(
m_strFolderPath.GetLength()));
UpdateData(FALSE);
// free memory
if(SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc)
pMalloc->Free(pidl);
pMalloc->Release();
m_EditPath.SetWindowText(m_strFolderPath);
}
thanks in advance.
Murali.M
|
|
|
|
|
When you get a buffer for the path with GetBuffer() , you need to specify a buffer size to allocate. At the moment, the string is empty, so GetLength() returns 0, so your buffer is 0 characters long. Allocate at least MAX_PATH characters and you should be ok. You also need to release the string buffer after.
CString m_strFolderPath;
LPMALLOC pMalloc = NULL;
LPITEMIDLIST pidl = NULL;
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(BROWSEINFO));
bi.hwndOwner = m_hWnd;
bi.lpszTitle = _T("Current folder is:");
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
pidl = SHBrowseForFolder(&bi);
if(pidl != NULL)
{
SHGetPathFromIDList(pidl, m_strFolderPath.GetBuffer(MAX_PATH));
m_strFolder.ReleaseBuffer();
UpdateData(FALSE);
if(SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc)
{
pMalloc->Free(pidl);
pMalloc->Release();
}
m_EditPath.SetWindowText(m_strFolderPath);
}
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|