广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2839 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
littleamuro
数位造型
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
文章表情[PHP][讨论] 有关php MessageBoxA()的问题
小弟这几天刚接触 PHP 程式,因之前并无学过其他程式 表情
因此在使用上发生了很多的疑问 表情
使用程式为 PHP Designer 2005
PHP程式版本为 Version 4.3.11 支援 WIN32
如果到 PHP函数内可以找到一个为 W32api Functions 的函数
在里面有一个范例
如下 :
<?php
// Define constants needed, taken from
// Visual Studio/Tools/Winapi/WIN32API.txt
define("MB_OK", 0);

// Load the extension in
dl("php_w32api.dll");

// Register the GetTickCount function from kernel32.dll
w32api_register_function("kernel32.dll",
                "GetTickCount",
                "long");
               
// Register the MessageBoxA function from User32.dll
w32api_register_function("User32.dll",
                "MessageBoxA",
                "long");

// Get uptime information
$ticks = GetTickCount();

// Convert it to a nicely displayable text
$secs = floor($ticks / 1000);
$mins = floor($secs / 60);
$hours = floor($mins / 60);

$str = sprintf("You have been using your computer for:" .
          "\r\n %d Milliseconds, or \r\n %d Seconds" .
          "or \r\n %d mins or\r\n %d hours %d mins.",
          $ticks,
          $secs,
          $mins,
          $hours,
          $mins - ($hours*60));

// Display a message box with only an OK button and the uptime text
MessageBoxA(NULL,
        $str,
        "Uptime Information",
        MB_OK);
?>

小弟努力了很多天都RUN不出来 表情
于是对他进行修修改改~~~
变成下面这个样子

<?php
// Define constants needed, taken from
// Visual Studio/Tools/Winapi/WIN32API.txt
define("MB_OK", 0);


//dl("php_w32api.dll"); <----- 程式原本为此行小弟改成下面那一行
$api = new win32;     <----- 修改后的程式



//$api->register_function("kernel32.dll","GetTickCount()","long"); <----- 程式原本为此行小弟改成下面那一行
$api->registerfunction("long GetTickCount() From kernel32.dll"); <----- 修改后的程式

//$api->register_function("User32.dll","MessageBoxA()","long");<----- 程式原本为此行小弟改成下面那一行

$api->registerfunction("long MessageBoxA() from User32.dll"); <----- 修改后的程式


//$ticks = GetTickCount(); "); <----- 程式原本为此行小弟改成下面那一行
$ticks =$api->GetTickCount(); <----- 修改后的程式


// Convert it to a nicely displayable text
$secs = floor($ticks / 1000);
$mins = floor($secs / 60);
$hours = floor($mins / 60);

$str = sprintf("You have been using your computer for:" ."\r\n %d Milliseconds, or \r\n %d Seconds" ."or \r\n %d mins or\r\n %d hours %d mins.",
          $ticks,$secs,$mins,$hours,$mins - ($hours*60));

// Display a message box with only an OK button and the uptime text
//$api->MessageBoxA(NULL,                   <---- 小弟推测此区应该有一个视窗显示,但是并无
//                     $str,             法执行,因此先将其注解,使程式不会发生 
//                   "Uptime Information",      错误
//                     MB_OK);                                 ---->
echo $str;                         <------小弟新增的,方便确认GetTickCount() 是否有作用
?>
输出结果如下:
You have been using your computer for: 12484671 Milliseconds, or 12484 Secondsor 208 mins or 3 hours 28 mins.

但是如果没将
$api->MessageBoxA(NULL,
            $str,
            "Uptime Information",
            MB_OK);
      echo $str;
标记为注解,程式及会发生错误
错误视窗内讯息如下:
PHP.EXE 应用程式错误   
        "0x003e2acc"指令参考的"0x00000000"记忆体.该记忆体不能为"READ".
        请按[确定]终止程式
        请按[取消]进行程式侦错

不知道是否有高手可以代为解答一下@@
因为发现很少人用PHP RUN WIN32API的样子 >@<
谢谢^^ 表情



献花 x0 回到顶端 [楼 主] From:台湾中华电信 | Posted:2005-08-26 23:02 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.016699 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言