Gets a comment field from a file in memory.
virtual L_INT LMemoryFile::ReadComment(LMemoryBuffer, pLCommentBuffer, uType, pLoadFileOption=NULL)
A LEAD LBuffer object that contains the file in memory.
A LEAD LBuffer object to be updated with the comment field, including the terminating NULL. You can pass NULL if you only want to get the length of the field (the return value).
The type of comment. Refer to Types of File Comments.
Pointer to optional extended load options. Pass NULL to use the default load options.
|>= 0||Length of the comment field.|
|< 0||An error occurred. Refer to Return Codes.|
Some file formats can contain comments, and some cannot, and each file format has its own set of comment types. When you save a file, the comments, which LEADTOOLS maintains in a global array, are saved in the file. The index into the array (specified using a constant) determines the type of comment, as described in Types of File Comments.
Before saving a file, you use the LFileSettings::SetComment function to specify the comments to be saved.
The [LMemoryFile:ReadComment function lets you read comments that are already saved in a file in memory. For more information refer to the LFileSettings::SetComment function.
The LMemoryBuffer parameter is passed by reference, and is a required parameter.
L_TCHAR szMessage; // MessageBox string
L_INT CommentLength; // Length of the comment string that we will get
LMemoryFile LeadMemFile ;
LBuffer LeadMemBuffer ;
LBuffer LeadCommBuffer ;
L_CHAR *pTextToSet = "Susie, the artist";
nRet = LeadFile.Load() ;
if(nRet != SUCCESS)
nRet = fileSettings.SetComment(CMNT_SZARTIST, (L_UCHAR *)pTextToSet, (L_INT) (strlen(pTextToSet) + 1));
if(nRet < 1)
nRet =LeadMemFile.Save(&LeadMemBuffer,FILE_TIF,8,NULL) ;
// Use the return value to get the length of a comment in the file
CommentLength = LeadMemFile.ReadComment (LeadMemBuffer, NULL, CMNT_SZARTIST, NULL);
if (CommentLength < 0)
MessageBox(NULL,TEXT("File has not comment ..."), TEXT("Read Memory Comment"),MB_OK) ;
// Get the actual comment from the file
nRet =LeadMemFile.ReadComment ( LeadMemBuffer, &LeadCommBuffer, CMNT_SZARTIST);
if(nRet < 0)
// Show the comment that was saved in the file
wsprintf (szMessage, TEXT("ARTIST:\n %hs"), LeadCommBuffer.Lock());
MessageBox (NULL, szMessage, TEXT("ARTIST"), MB_OK);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries