第2个回答 推荐于2018-03-21
参考代码如下:
HANDLE hFile = CreateFile( lpFileName,
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL );
if ( hFile )
{
HGLOBAL hMem = NULL;
GetHGlobalFromStream( pStream, &hMem );//
LPVOID lpData = GlobalLock( hMem );
DWORD dwBytesWritten;
bResult = WriteFile( hFile, lpData, lBytesStreamed, &dwBytesWritten, NULL );
bResult &= ( dwBytesWritten == (DWORD)lBytesStreamed );
// clean up
GlobalUnlock(hMem);
CloseHandle(hFile);