Article ID: 179364
Article Last Modified on 11/21/2006
LPTSTR lpszTitle;
WORD cbBuf;
short nErr;
// Find the length needed for the title (including null terminator).
// lpszFile should contain the name and location of the file.
cbBuf = GetFileTitle(lpszFile,NULL,0);
if (cbBuf < 0) {
// There was an error with lpszFile.
}
lpszTitle = (LPTSTR) GlobalAlloc(GPTR, sizeof(TCHAR)* cbBuf);
if (lpszTitle) {
nErr = GetFileTitle(lpszFile,lpszTitle,cbBuf);
if (0 == nErr) {
// lpszTitle now has the appropriate display name of the
// file, including or excluding the extension per the
// user's preferences.
DoStuffWithTheTitle(lpszTitle);
} else {
// There was an error.
if (nErr < 0) {
// error in lpszFile's format.
} else {
// nErr > 0 means lpszTitle was too small a buffer.
}
}
GlobalFree(lpszTitle);
}
Keywords: kbhowto KB179364