bool CMediaFileLogisticsFormView::GetMediaSizes(int *out_pnWidth, int *out_pnHeight)
{
bool bOK = false;
char cmd[300];
char lpszReturnString[128];
int len, i;
(*out_pnWidth) = (*out_pnHeight) = i = 0;
// Build the command string.
wsprintf(cmd, "where %s source", m_strMPEGAlias);
memset(lpszReturnString,'\0',sizeof(lpszReturnString));
// Send the command.
if (mciSendString(cmd, lpszReturnString, sizeof(lpszReturnString), NULL) == 0)
{
// The rectangle is returned as "x y dx dy".
// Both x and y are 0 because this is the source
// rectangle. Translate the string into the RECT
// structure.
char *p;
len = strlen(lpszReturnString);
p = lpszReturnString; // point to the return string
while ((*p != ' ') && (i<len)) // go past the x (0)
{
p++; i++;
}
while ((*p == ' ') && (i<len)) // go past spaces
{
p++; i++;
}
while ((*p != ' ') && (i<len)) // go past the y (0)
{
p++; i++;
}
while ((*p == ' ') && (i<len)) // go past spaces
{
p++; i++;
}
// Retrieve the width.
while ((*p != ' ') && (i<len))
{
(*out_pnWidth) = (10 * (*out_pnWidth)) + (*p - '0');
p++; i++;
}
while ((*p == ' ') && (i<len)) // go past spaces
{
p++; i++;
}
// Retrieve the height.
while ((*p != ' ') && (i<len))
{
(*out_pnHeight) = (10 * (*out_pnHeight)) + (*p - '0');
p++; i++;
}
bOK = true;
}
return bOK;
}