本文整理汇总了C++中MemBlock::GetDataPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ MemBlock::GetDataPointer方法的具体用法?C++ MemBlock::GetDataPointer怎么用?C++ MemBlock::GetDataPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemBlock
的用法示例。
在下文中一共展示了MemBlock::GetDataPointer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteFile
int WriteFile(const TCHAR* filePath,const MemBlock& pMemBlock){
HANDLE hFile = CreateFile((TCHAR*) filePath, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
UINT32 un32NumberOfBytesWritten;
if (hFile != INVALID_HANDLE_VALUE){
// Write the bitmap header and bitmap bits to the file
BOOL ret = ::WriteFile(hFile, (LPCVOID) pMemBlock.GetDataPointer(), pMemBlock.GetSize(), (LPDWORD)&un32NumberOfBytesWritten, 0);
if(ret==0) woodychang0611::diagnostics::SendWarning(_T("File Write Failed!"));
CloseHandle(hFile);// Close the file
}
return 0;
}
示例2: ReadFile
int ReadFile(const TCHAR* filePath,MemBlock& pMemBlock){
HANDLE hFile = CreateFile((TCHAR*) filePath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hFile != INVALID_HANDLE_VALUE){
//Maximum File Size 4GB (2^32);
UINT32 un32FileSize;
UINT32 un32NumberOfBytesRead ;
un32FileSize =GetFileSize(hFile,NULL);
if(un32FileSize){
pMemBlock.SetSize(un32FileSize);
}
BOOL ret = ::ReadFile(hFile,(LPVOID) pMemBlock.GetDataPointer(), un32FileSize,(LPDWORD) &un32NumberOfBytesRead,0);
//
if(ret==0) woodychang0611::diagnostics::SendWarning(_T("File Read Failed!"));
CloseHandle(hFile);// Close the file
return 0;
}
return -1;
}