|
Hi
I want to write information to the registry 'HKEY_LOCAL_MACHINE\Software'.
I don't think it is possible by using the MFC function (WriteProfileString).
How can i fix the problem without having to fear that it won't run perfectly on all windows systems?
What do you guys/girls recommend me?
Greetings
Jens
|
|
|
|
|
No its not possible using the standard MFC functions. We needed to do the same in our app. We took the existing code in the GEtProfileString() and the ancillary functions, pasted them verbatum and changed all the HKEY_CURRENT_USER references to HKEY_LOCAL_MACHINE. After adding a LM to the end of each function name it worked really well.
The only issue you may have is access rights. Depending on how the admin sets up registry access, your application could possible be blocked from writing to HLM.
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Use CRegKey class to read and write to registry.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
I've just read this article:
'http://www.endurasoft.com/techtalk/regdemo2.htm'
Does this API work on all Windows version correctly?
Greetings,
Jens
|
|
|
|
|
Those SDK Functions will surely work on all window platforms.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Well, i'll try the CRegKey class first out.
If that works good enough, i won't use the SDK functions.
Greetings
Jens
|
|
|
|
|
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
|
|
|
|
|