program ScrnSize;<br><br>uses<br> Windows;<br><br> // 格式化输出函数 {标题} {输出格式} {输出变量列表}<br>procedure MessageBoxPrintf(Caption, Format: PChar; const Args: array of const);<br>var<br> OutBuff: array[0..100] of Char; // 最终输出文字<br> OutList: array of LongWord; // 输出变量列表<br> J: Integer;<br>begin<br> SetLength(OutList, 0);<br> for J := Low(Args) to High(Args) do // Args -&gt; OutList<br> begin<br> case Args[J].VType of // 这里仅处理了两种类型<br> vtInteger: begin<br> SetLength(OutList, Length(OutList)+1);<br> OutList[High(OutList)] := Args[J].VInteger;<br> end;<br> <br> vtString : begin<br> SetLength(OutList, Length(OutList)+1);<br> OutList[High(OutList)] := LongWord(Args[J].VString);<br> end;<br> end;<br> end;<br> if Length(OutList) = Length(Args) then // 列表成员均合法<br> begin<br> wvsprintf(OutBuff, Format, @OutList[0]); // 转换<br> MessageBox(0, OutBuff, Caption, 0); // 输出<br> end;<br>end;<br><br>var<br> cxScreen, cyScreen: Integer;<br><br>begin<br> cxScreen := GetSystemMetrics(SM_CXSCREEN); // 屏幕宽度<br> cyScreen := GetSystemMetrics(SM_CYSCREEN); // 屏幕高度<br> MessageBoxPrintf('ScrnSize', <br> 'The screen is %i pixels wide by %i pixels high.',<br> [cxScreen, cyScreen]);<br>end.<br>