molistok
2011-09-09 08:42:37 UTC
Hi,
I have implemented in my application a option to associate the
extension of one type of file automatically after to push a button. In
all computers this option works fine. But I have one user that in her
computer this option don't work fine. I have checked that in this
computer these lines don't work fine:
HKEY hOpenKey = HKEY_CLASSES_ROOT;
LPCTSTR szKey = ".abc";
LPCTSTR szValue = "";
LPCTSTR szData = "example";
BOOL bRetVal = FALSE;
DWORD dwDisposition;
DWORD dwReserved = 0;
HKEY hTempKey = (HKEY)0;
// length specifier is in bytes, and some TCHAR
// are more than 1 byte each
DWORD dwBufferLength = lstrlen(szData) * sizeof(TCHAR);
if( ERROR_SUCCESS == ::RegCreateKeyEx(hOpenKey, szKey, dwReserved,
(LPTSTR)0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE , 0,
&hTempKey, &dwDisposition) )
{
// dwBufferLength must include size of terminating nul
// character when using REG_SZ with RegSetValueEx function
dwBufferLength += sizeof(TCHAR);
if( ERROR_SUCCESS == ::RegSetValueEx(hTempKey, (LPTSTR)szValue,
dwReserved, REG_SZ, (LPBYTE)szData, dwBufferLength) )
{
bRetVal = TRUE;
}
}
In this computer sometimes when the application call the function
RegCreateKeyEx it fail. Always in this computer when for example the
value of szkey is: szkey = ".abc\\shell\\open\\command" the function
RegCreateKeyEx fail and therefore the computer can not complete the
association of the extension.
Can any help me please? Have I to check something in this computer?
If I have posted in a wrong group please tell me what is the best
group to ask this question.
Thanks.
I have implemented in my application a option to associate the
extension of one type of file automatically after to push a button. In
all computers this option works fine. But I have one user that in her
computer this option don't work fine. I have checked that in this
computer these lines don't work fine:
HKEY hOpenKey = HKEY_CLASSES_ROOT;
LPCTSTR szKey = ".abc";
LPCTSTR szValue = "";
LPCTSTR szData = "example";
BOOL bRetVal = FALSE;
DWORD dwDisposition;
DWORD dwReserved = 0;
HKEY hTempKey = (HKEY)0;
// length specifier is in bytes, and some TCHAR
// are more than 1 byte each
DWORD dwBufferLength = lstrlen(szData) * sizeof(TCHAR);
if( ERROR_SUCCESS == ::RegCreateKeyEx(hOpenKey, szKey, dwReserved,
(LPTSTR)0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE , 0,
&hTempKey, &dwDisposition) )
{
// dwBufferLength must include size of terminating nul
// character when using REG_SZ with RegSetValueEx function
dwBufferLength += sizeof(TCHAR);
if( ERROR_SUCCESS == ::RegSetValueEx(hTempKey, (LPTSTR)szValue,
dwReserved, REG_SZ, (LPBYTE)szData, dwBufferLength) )
{
bRetVal = TRUE;
}
}
In this computer sometimes when the application call the function
RegCreateKeyEx it fail. Always in this computer when for example the
value of szkey is: szkey = ".abc\\shell\\open\\command" the function
RegCreateKeyEx fail and therefore the computer can not complete the
association of the extension.
Can any help me please? Have I to check something in this computer?
If I have posted in a wrong group please tell me what is the best
group to ask this question.
Thanks.