廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2824 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為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.012591 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言