Discussion:
I associate extension files with my application correctly but in one computer don't work fine
(too old to reply)
molistok
2011-09-09 08:42:37 UTC
Permalink
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.
David Lowndes
2011-09-09 09:14:48 UTC
Permalink
Post by molistok
if( ERROR_SUCCESS == ::RegCreateKeyEx(hOpenKey, szKey, dwReserved,
(LPTSTR)0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE , 0,
&hTempKey, &dwDisposition) )
...
In this computer sometimes when the application call the function
RegCreateKeyEx it fail.
What does the return code value tell you is the reason for the
failure?

Dave
molistok
2011-09-12 09:09:53 UTC
Permalink
Post by David Lowndes
Post by molistok
if( ERROR_SUCCESS == ::RegCreateKeyEx(hOpenKey, szKey, dwReserved,
   (LPTSTR)0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE , 0,
   &hTempKey, &dwDisposition) )
...
In this computer sometimes when the application call the function
RegCreateKeyEx it fail.
What does the return code value tell you is the reason for the
failure?
Dave
Thanks for the reply. I do GetLastError but the function return the
value 0.
David Lowndes
2011-09-12 09:20:10 UTC
Permalink
Post by molistok
Thanks for the reply. I do GetLastError but the function return the
value 0.
You don't use GetLastError with the Reg* functions, the error/success
code is the return value of the Reg* function.

Dave
molistok
2011-09-13 08:56:31 UTC
Permalink
Post by David Lowndes
Post by molistok
Thanks for the reply. I do GetLastError but the function return the
value 0.
You don't use GetLastError with the Reg* functions, the error/success
code is the return value of the Reg* function.
Dave
Ok, it's true, I can see the error with the return of Reg functions.
Thanks.
Nobody
2011-09-09 12:20:17 UTC
Permalink
Post by molistok
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
HKEY hOpenKey = HKEY_CLASSES_ROOT;
Administrative privileges are required to write to HKEY_CLASSES_ROOT. You
either need to do it in the installer, or use the following key to change it
per user:

HKEY_CURRENT_USER\Software\Classes

See this article:

HKEY_CLASSES_ROOT Key
http://msdn.microsoft.com/en-us/library/ms724475.aspx
molistok
2011-09-12 09:10:35 UTC
Permalink
Post by Nobody
Post by molistok
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
HKEY hOpenKey = HKEY_CLASSES_ROOT;
Administrative privileges are required to write to HKEY_CLASSES_ROOT. You
either need to do it in the installer, or use the following key to change it
HKEY_CURRENT_USER\Software\Classes
HKEY_CLASSES_ROOT Keyhttp://msdn.microsoft.com/en-us/library/ms724475.aspx
Thanks, I will try to change the key and therefore use
HKEY_CURRENT_USER\Software\Classes

Thanks.
molistok
2011-09-13 08:57:28 UTC
Permalink
Post by molistok
Post by Nobody
Post by molistok
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
HKEY hOpenKey = HKEY_CLASSES_ROOT;
Administrative privileges are required to write to HKEY_CLASSES_ROOT. You
either need to do it in the installer, or use the following key to change it
HKEY_CURRENT_USER\Software\Classes
HKEY_CLASSES_ROOT Keyhttp://msdn.microsoft.com/en-us/library/ms724475.aspx
Thanks, I will try to change the key and therefore use
HKEY_CURRENT_USER\Software\Classes
Thanks.
I think that now with this change work fine for all users.
Thanks.

Loading...