【PB】在PB中調用外部程式並判斷其運行結束

來源:互聯網
上載者:User

在PB中經常要調用外部程式並等待此程式運行結束後顯示相關資訊。

如我們要備份Adaptive Server Anywhere 6.0資料庫,在備份結束後顯示"備份完成!"的提示資訊,如果在調用備份程式dbbackup後馬上用messagebox顯示提示資訊,那麼程式運行時則會出現這種情況: dbbackup備份程式還在運行,"備份完成!"的提示就已經顯示了,顯然不符合我們的設想。對於這種情況,我們可以藉助API函數FindWindowA()、IsWindow()和PB本身函數yield()來解決。

聲明API函數:
Function long FindWindowA (String lpClassName , String lpWindowName ) Library "user32.dll"

Function boolean IsWindow (Long hwnd ) Library "user32.dll"
調用:
ulong ll_handle
int li_loop
SetPointer(HourGlass!) //設定滑鼠指標
//運行備份資料庫程式dbbackup,並使其最小化
run("dbbackup -c ~"uid=dba;pwd=sql; dbf=D:/Sybase/Adaptive Server Anywhere 6.0/asademo.db~" d:/backup", Minimized!)

ll_handle = 0
//迴圈至dbbackup視窗開啟
Do While ll_handle = 0
    ll_handle = FindWindowA("tty","dbbackup")
    yield() //
loop     
//等待dbbackup視窗關閉
Do While isWindow(ll_handle)
    Yield()
Loop
//應用執行完成
MessageBox("提示資訊", "備份完成!")

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.