1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-29 01:42:12 +01:00
Files
archived-doc-es/reference/w32api/examples.xml
Pedro Antonio Gil Rodríguez 79981a8d71 Finished reference/w32api/*
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@293790 c90b9560-bf6c-de11-be94-00142212c4b1
2010-01-20 22:21:53 +00:00

84 lines
2.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 288721 $ -->
<!-- EN-Revision: af4410a7e15898c3dbe83d6ea38246745ed9c6fb Maintainer: seros Status: ready -->
<chapter xml:id="w32api.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="w32api.examples-uptime">
<para>
Este ejemplo obtiene la cantidad de tiempo que el sistema ha estado ejecutándose y
lo muestra en un cuadro de mensaje.
</para>
<example>
<title>Obtener el tiempo de funcionamiento y mostrarlo en un cuadro de mensaje</title>
<programlisting role="php">
<![CDATA[
<?php
// Definir las constantes necesarias, tomadas de
// Visual Studio/Tools/Winapi/WIN32API.txt
define("MB_OK", 0);
// Cargar la extensión en
dl("php_w32api.dll");
// Registrar la función GetTickCount desde kernel32.dll
w32api_register_function("kernel32.dll",
"GetTickCount",
"long");
// Registrar la función MessageBoxA desde User32.dll
w32api_register_function("User32.dll",
"MessageBoxA",
"long");
// Obtener la información del tiempo de funcionamiento
$ticks = GetTickCount();
// Convertirlo a un texto mostrable más amable
$segs = floor($ticks / 1000);
$mins = floor($segs / 60);
$horas = floor($mins / 60);
$str = sprintf("Ha estado usando su ordenador durante:" .
"\r\n %d Milisegundos, o \r\n %d Segundos" .
"o \r\n %d minutos o\r\n %d horas %d minutos.",
$ticks,
$segs,
$mins,
$horas,
$mins - ($horas*60));
// Mostrar el cuadro de mensaje con sólo un botón OK y el texto de tiempo de funcionamiento
MessageBoxA(NULL,
$str,
"Información del Tiempo de Funcionamiento",
MB_OK);
?>
]]>
</programlisting>
</example>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->