Здравствуйте, 0x64Rm, Вы писали:
P>>он же не выполняет HeapFree. Речь идет о том, что блок __finally вообще не исполняется.
R>Привет еще раз. Очень интересно! Извини что я так настойчив но здоровое любопытсво не отпускает
R>Будь другом попробуй вот это еще (последнее и если не пройдет я склонен считать, что это глюк С)
R>R> __finally
R> {
R> HeapFree( GetProcessHeap(), 0, ptr );
R> MessageBox(NULL,"Hello form __finally!","",MB_OK);
R> }
R>
R>видишь мессаджбокс?
[skip]
Этот пример работает. А вот изначальный код, где у меня не выполняется __finally:
BOOL GetAccountSid(LPCTSTR SystemName, LPCTSTR AccountName, PSID *Sid )
{
LPTSTR RefDomain = NULL;
DWORD cbSid = 128; // initial allocation attempt
DWORD cbRefDomain = 16; // initial allocation size
SID_NAME_USE peUse;
BOOL bSuccess = FALSE; // assume this function will fail
__try
{
// initial memory allocations
//
if( ( *Sid = HeapAlloc( GetProcessHeap(),
0,
cbSid
)) == NULL )
__leave;
if( ( RefDomain = (LPTSTR)HeapAlloc( GetProcessHeap(),
0,
cbRefDomain )) == NULL )
__leave;
// Obtain the SID of the specified account on the specified system.
//
while( !LookupAccountName(
SystemName, // machine to lookup account on
AccountName, // account to lookup
*Sid, // SID of interest
&cbSid, // size of SID
RefDomain, // domain account was found on
&cbRefDomain,
&peUse ))
{
if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER )
{
// reallocate memory
//
if( (*Sid = HeapReAlloc( GetProcessHeap(),
0,
*Sid,
cbSid )) == NULL)
__leave;
if( (RefDomain = (LPTSTR)HeapReAlloc( GetProcessHeap(),
0,
RefDomain,
cbRefDomain )) == NULL)
__leave;
}
else
__leave;
}
// Indicate success.
//
bSuccess = TRUE;
}
__finally
{
// Cleanup and indicate failure, if appropriate.
HeapFree( GetProcessHeap(), 0, RefDomain );
if(!bSuccess)
{
if(*Sid != NULL)
{
HeapFree( GetProcessHeap(), 0, *Sid);
*Sid = NULL;
}
}
} // finally
return bSuccess;
}
выполняю по шагам, доходит до __finally и перескакивает на return.