EDN Admin
Well-known member
I have a cab extractor. The code works fine on Windows 2000, but fails on Windows 7, or Windows 2008, when needing a second cab.
The returned error is Invalid Data (code 13), when extracting data which spans over more than one cab file.
The problem occurs both in unicode as in in Ansi-version (or multi-byte).
<div style="color:Black;background-color:White; <pre>
UINT CALLBACK EnumerateCab (PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
{
<span style="color:Blue; switch (Notification)
{
<span style="color:Blue; case SPFILENOTIFY_FILEEXTRACTED:
<span style="color:Blue; return NO_ERROR;
<span style="color:Blue; case SPFILENOTIFY_FILEINCABINET:
{
CExtractLogDlg * pDlg = (CExtractLogDlg *) Context;
LPCTSTR pCab = (LPCTSTR) Param2, pEnd;
FILE_IN_CABINET_INFO *pInfo = (FILE_IN_CABINET_INFO *) Param1;
<span style="color:Blue; if (pDlg->m_extract.IsEmpty ())
{
pEnd = SafeString::FindReverse (pCab, _T(\)) + 1;
CListCtrl *pListCtrl = (CListCtrl *) pDlg->GetDlgItem (IDC_FILES);
pListCtrl->SetItemText (pListCtrl->InsertItem (pListCtrl->GetItemCount (), pInfo->NameInCabinet), 1, pEnd);
<span style="color:Blue; return FILEOP_SKIP;
}
<span style="color:Blue; else <span style="color:Blue; if (pDlg->m_extract == pInfo->NameInCabinet)
{
<span style="color:Blue; if (pDlg->m_filename.IsEmpty ())
wsprintf (pInfo->FullTargetName, _T(<span style="color:#A31515; "%s%s"), pDlg->m_destination, pInfo->NameInCabinet + pDlg->m_removeChars);
<span style="color:Blue; else
{
wsprintf (pInfo->FullTargetName, _T(<span style="color:#A31515; "%s%s"), pDlg->m_destination, ((LPCTSTR) pDlg->m_filename) + pDlg->m_removeChars);
pDlg->m_filename.Empty ();
} <span style="color:Green; // if
pDlg->m_extracted.AddFile (pInfo->FullTargetName);
<span style="color:Blue; return FILEOP_DOIT;
}
<span style="color:Blue; else
<span style="color:Blue; return FILEOP_SKIP;
} <span style="color:Green; // if
<span style="color:Blue; break;
<span style="color:Blue; case SPFILENOTIFY_NEEDNEWCABINET:
{
CABINET_INFO *pInfo = (CABINET_INFO *) Param1;
LPTSTR pCab = (LPTSTR) Param2;
wsprintf (pCab, _T(<span style="color:#A31515; "%s%s"), pInfo->CabinetPath, pInfo->CabinetFile);
CFileFind fileFind;
<span style="color:Blue; if (fileFind.FindFile (pCab))
<span style="color:Blue; return NO_ERROR;
<span style="color:Blue; else
<span style="color:Blue; return ERROR_FILE_NOT_FOUND;
} <span style="color:Green; // if
<span style="color:Blue; break;
} <span style="color:Green; // switch
<span style="color:Blue; return 0;
}
[/code]
<hr class="sig Geert
View the full article
The returned error is Invalid Data (code 13), when extracting data which spans over more than one cab file.
The problem occurs both in unicode as in in Ansi-version (or multi-byte).
<div style="color:Black;background-color:White; <pre>
UINT CALLBACK EnumerateCab (PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
{
<span style="color:Blue; switch (Notification)
{
<span style="color:Blue; case SPFILENOTIFY_FILEEXTRACTED:
<span style="color:Blue; return NO_ERROR;
<span style="color:Blue; case SPFILENOTIFY_FILEINCABINET:
{
CExtractLogDlg * pDlg = (CExtractLogDlg *) Context;
LPCTSTR pCab = (LPCTSTR) Param2, pEnd;
FILE_IN_CABINET_INFO *pInfo = (FILE_IN_CABINET_INFO *) Param1;
<span style="color:Blue; if (pDlg->m_extract.IsEmpty ())
{
pEnd = SafeString::FindReverse (pCab, _T(\)) + 1;
CListCtrl *pListCtrl = (CListCtrl *) pDlg->GetDlgItem (IDC_FILES);
pListCtrl->SetItemText (pListCtrl->InsertItem (pListCtrl->GetItemCount (), pInfo->NameInCabinet), 1, pEnd);
<span style="color:Blue; return FILEOP_SKIP;
}
<span style="color:Blue; else <span style="color:Blue; if (pDlg->m_extract == pInfo->NameInCabinet)
{
<span style="color:Blue; if (pDlg->m_filename.IsEmpty ())
wsprintf (pInfo->FullTargetName, _T(<span style="color:#A31515; "%s%s"), pDlg->m_destination, pInfo->NameInCabinet + pDlg->m_removeChars);
<span style="color:Blue; else
{
wsprintf (pInfo->FullTargetName, _T(<span style="color:#A31515; "%s%s"), pDlg->m_destination, ((LPCTSTR) pDlg->m_filename) + pDlg->m_removeChars);
pDlg->m_filename.Empty ();
} <span style="color:Green; // if
pDlg->m_extracted.AddFile (pInfo->FullTargetName);
<span style="color:Blue; return FILEOP_DOIT;
}
<span style="color:Blue; else
<span style="color:Blue; return FILEOP_SKIP;
} <span style="color:Green; // if
<span style="color:Blue; break;
<span style="color:Blue; case SPFILENOTIFY_NEEDNEWCABINET:
{
CABINET_INFO *pInfo = (CABINET_INFO *) Param1;
LPTSTR pCab = (LPTSTR) Param2;
wsprintf (pCab, _T(<span style="color:#A31515; "%s%s"), pInfo->CabinetPath, pInfo->CabinetFile);
CFileFind fileFind;
<span style="color:Blue; if (fileFind.FindFile (pCab))
<span style="color:Blue; return NO_ERROR;
<span style="color:Blue; else
<span style="color:Blue; return ERROR_FILE_NOT_FOUND;
} <span style="color:Green; // if
<span style="color:Blue; break;
} <span style="color:Green; // switch
<span style="color:Blue; return 0;
}
[/code]
<hr class="sig Geert
View the full article