virtual L_INT LFile::ReadComment(uType, pLBuffer, pLoadFileOption=NULL)
Gets a single comment, a group of comments or several groups of comments from a file.
The type of comment. Refer to Types of File Comments. A group of comments may be obtained such as CMNT_FPXSUMMARYINFORMATION, or more than one group of comments may be retrieved by using OR as in CMNT_FPXSUMMARYINFORMATION | CMNT_FPXFILESOURCEGROUP, or all comments may be obtained by using CMNT_ALL. See Example listed below. For more information concerning FlashPix file comments, see FlashPix File Comments.
Pointer to the buffer object that will hold all the 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.|
The basic order of function calls to retrieve comments is as follows:
To write comments to a file, all the comments you wish to add to a new file must be set. LFileSettings::SetComment sets each comment individually, but it does not save the comments to the file, it prepares the values for the next save.. Once all comments are set, the comments are saved using any function which saves files, such as LFile::SaveFile or LFile::Save when creating a new file. If you wish to change a comment in an existing file, use LFile::WriteComment.
This example demonstrates all of the functions related to comments for TIFF files.
It clears all comments, sets a new comment, gets the comment from memory,
saves a file with the comment, then gets the comment from the file.
L_CHAR *pTextToSet = "Susie, the artist";
//Set the comment
nRet = fileSettings.SetComment(CMNT_SZARTIST, (L_UCHAR *)pTextToSet, (L_INT) (strlen(pTextToSet) + 1));
if(nRet < 0)
//Get the length of a comment
CommentLength = fileSettings.GetComment(CMNT_SZARTIST, NULL, 0);
//Allocate and lock a zero-filled buffer for the comment
hTextToGet = GlobalAlloc(GPTR, CommentLength);
pTextToGet = (L_CHAR *)GlobalLock(hTextToGet);
//Get the actual comment
fileSettings.GetComment(CMNT_SZARTIST, (L_UCHAR *)pTextToGet, CommentLength);
//Show the comment that will be saved
::MessageBox(NULL, message, TEXT("Saving Artist Comment"), MB_OK);
// Free memory
//Load, and then save the image with the new comment
nRet = LeadBitmap.Load();
if(nRet != SUCCESS)
nRet = LeadBitmap.Save(FILE_TIF, 8, 0, NULL, NULL);
if(nRet != SUCCESS)
//Get the length of a comment in the file
CommentLength = LeadBitmap.File()->ReadComment(CMNT_SZARTIST, NULL);
//Get the actual comment from the file
nRet = LeadBitmap.File()->ReadComment(CMNT_SZARTIST, &LeadBuffer);
if(nRet < 1)
//Show the comment that was saved in the file
::MessageBox (NULL, message, TEXT("Artist comment"), MB_OK);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries