Hi all,
I've run into a bit of a problem in a piece of software I'm working on. I am writing a installer that runs on Pocket PC 2003 and above. The installer is written in eVC++ 4.0. Basically, the installer has a bunch of Resources added to it in the project. These resources are just imported .CAB files. The interface steps through and guides them through installation in a specific order.
When a cab is installed, the resource is locked, a file is created, WriteFile(...) is called, and the file is closed and executed. It seems to be going well. However, occaisionally I have a problem. Through debugging, I've noticed that WriteFile is writing out less than the number of bytes than the resource. Of course, this makes the .CAB invalid and causes problems... Here is the code snippet that writes out the cab file:
So for example, dwSize (the real size of the resource) could be 1128448 bytes, but WriteFile returns 999876 to the dwNumberOfBytesWritten. I've tried looping WriteFile until TotalBytesWritten = dwSize, but subsequent calls write out 0 bytes... Memory is not an issue. I have 8MB free storage, and 20 running.
Also, this seems to be happening primarily on 2003 2nd Edition devices. My vanilla 2003 device has no issues! Any ideas?
I've run into a bit of a problem in a piece of software I'm working on. I am writing a installer that runs on Pocket PC 2003 and above. The installer is written in eVC++ 4.0. Basically, the installer has a bunch of Resources added to it in the project. These resources are just imported .CAB files. The interface steps through and guides them through installation in a specific order.
When a cab is installed, the resource is locked, a file is created, WriteFile(...) is called, and the file is closed and executed. It seems to be going well. However, occaisionally I have a problem. Through debugging, I've noticed that WriteFile is writing out less than the number of bytes than the resource. Of course, this makes the .CAB invalid and causes problems... Here is the code snippet that writes out the cab file:
- Code:
void CopyCabResource(WORD wResource)
{
SetCursor(LoadCursor(NULL, IDC_WAIT));
HGLOBAL hResD = NULL;
void *pvRes = NULL;
DWORD dwSize = NULL;
HRSRC hResInfo = NULL;
///
/// Find the resource and load it into memory
///
hResInfo = FindResource(hInst, MAKEINTRESOURCE(wResource), L"CAB");
hResD = LoadResource(hInst, hResInfo);
pvRes = LockResource(hResD);
dwSize = SizeofResource(hInst, hResInfo);
///
/// Create the temp directory
///
CreateDirectory(tempCabPath, NULL);
///
/// Create the file
///
HANDLE hCabFile = INVALID_HANDLE_VALUE;
hCabFile = CreateFile(tempCabFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL);
///
/// Write to the file
///
DWORD dwNumberOfBytesWritten = 0;
WriteFile(hCabFile, pvRes, dwSize, &dwNumberOfBytesWritten, NULL);
///
/// Close the file
///
CloseHandle(hCabFile);
SetCursor(NULL);
}
So for example, dwSize (the real size of the resource) could be 1128448 bytes, but WriteFile returns 999876 to the dwNumberOfBytesWritten. I've tried looping WriteFile until TotalBytesWritten = dwSize, but subsequent calls write out 0 bytes... Memory is not an issue. I have 8MB free storage, and 20 running.
Also, this seems to be happening primarily on 2003 2nd Edition devices. My vanilla 2003 device has no issues! Any ideas?