CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

如果在 VB 里调用一个程序,几秒后又强行关闭掉它啊?

楼主jykuwang(狂人)2004-12-03 18:13:34 在 VB / 基础类 提问

如果在   VB   里调用一个程序,几秒后又强行关闭掉它啊? 问题点数:30、回复次数:5Top

1 楼cosio()回复于 2004-12-03 18:19:33 得分 0

延迟函数  
  me.hideTop

2 楼jykuwang(狂人)回复于 2004-12-03 18:22:15 得分 0

可能你误解我的意思了,  
  我的意思是说,比如我在   VB   里打开了记事本,5   秒钟后又关闭它,怎么做?Top

3 楼caimps(苦乐斋主人)回复于 2004-12-03 18:29:36 得分 0

timer  
   
  Top

4 楼wwqna(york)回复于 2004-12-03 18:30:14 得分 30

Private   Declare   Function   FindWindow   Lib   "user32"   Alias   "FindWindowA"   (ByVal   lpClassName   As   Long,   ByVal   lpWindowName   As   Long)   As   Long  
  Public   Declare   Function   CloseWindow   Lib   "user32"   Alias   "CloseWindow"   (ByVal   hwnd   As   Long)   As   Long  
   
  Private   Declare   Function   GetParent   Lib   "user32"   (ByVal   hwnd   As   Long)   As   Long  
  Private   Declare   Function   SetParent   Lib   "user32"   (ByVal   hWndChild   As   Long,   ByVal   hWndNewParent   As   Long)   As   Long  
  Private   Declare   Function   GetWindowThreadProcessId   Lib   "user32"   (ByVal   hwnd   As   Long,   lpdwProcessId   As   Long)   As   Long  
  Private   Declare   Function   GetWindow   Lib   "user32"   (ByVal   hwnd   As   Long,   ByVal   wCmd   As   Long)   As   Long  
  Private   Declare   Function   LockWindowUpdate   Lib   "user32"   (ByVal   hwndLock   As   Long)   As   Long  
  Private   Declare   Function   GetDesktopWindow   Lib   "user32"   ()   As   Long  
  Private   Declare   Function   DestroyWindow   Lib   "user32"   (ByVal   hwnd   As   Long)   As   Long  
  Private   Declare   Function   TerminateProcess   Lib   "kernel32"   (ByVal   hProcess   As   Long,   ByVal   uExitCode   As   Long)   As   Long  
  Private   Declare   Function   GetCurrentProcess   Lib   "kernel32"   ()   As   Long  
  Private   Declare   Function   Putfocus   Lib   "user32"   Alias   "SetFocus"   (ByVal   hwnd   As   Long)   As   Long  
  Const   GW_HWNDNEXT   =   2  
  Dim   mWnd   As   Long  
  Function   InstanceToWnd(ByVal   target_pid   As   Long)   As   Long  
          Dim   test_hwnd   As   Long,   test_pid   As   Long,   test_thread_id   As   Long  
          'Find   the   first   window  
          test_hwnd   =   FindWindow(ByVal   0&,   ByVal   0&)  
          Do   While   test_hwnd   <>   0  
                  'Check   if   the   window   isn't   a   child  
                  If   GetParent(test_hwnd)   =   0   Then  
                          'Get   the   window's   thread  
                          test_thread_id   =   GetWindowThreadProcessId(test_hwnd,   test_pid)  
                          If   test_pid   =   target_pid   Then  
                                  InstanceToWnd   =   test_hwnd  
                                  Exit   Do  
                          End   If  
                  End   If  
                  'retrieve   the   next   window  
                  test_hwnd   =   GetWindow(test_hwnd,   GW_HWNDNEXT)  
          Loop  
  End   Function  
  Private   Sub   Form_Load()  
          Dim   Pid   As   Long  
          'Lock   the   window   update  
          LockWindowUpdate   GetDesktopWindow  
          'Execute   notepad.Exe  
          Pid   =   Shell("c:\windows\notepad.exe",   vbNormalFocus)  
          If   Pid   =   0   Then   MsgBox   "Error   starting   the   app"  
          'retrieve   the   handle   of   the   window  
          mWnd   =   InstanceToWnd(Pid)  
       
          sleep   1000                               '停1称  
          closeWindow   mWnd                   '关掉它  
   
          'Unlock   windowupdate  
          LockWindowUpdate   False  
  End   Sub  
  Private   Sub   Form_Unload(Cancel   As   Integer)  
          'Unload   notepad  
          DestroyWindow   mWnd  
          'End   this   program  
          TerminateProcess   GetCurrentProcess,   0  
  End   SubTop

5 楼creazyfish(梳分头的鱼)回复于 2004-12-03 18:35:33 得分 0

用timer控件好了  
  Top

相关问题

  • 如何在JAVA中调用VB程序
  • 在VB中怎样调用外程序?
  • VB中调用shell程序(.bat)
  • 用shell调用的外部程序如何用程序关闭??
  • 如何通过java程序调用vb程序
  • 请问VBA程序(调用了VB程序)如何发布?
  • VB程序调用我写的DLL打开串口程序?
  • vc程序调用vb程序的问题
  • 程序调用
  • 程序调用!!

关键词

  • vb
  • longprivate
  • mwnd
  • byval
  • lockwindowupdate
  • closewindow
  • hwnd
  • 关闭
  • pid
  • long

得分解答快速导航

  • 帖主:jykuwang
  • wwqna

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo