var
  hd: THandle;begin
          Hd := FindWindow ('OpusApp',nil);
          if Hd > 0 then
            showmessage('已打开Word')
          else
            showmessage('没有打开Word');

解决方案 »

  1.   

      if   H>0  then   //   如果找到则发送自定义的消息并退出
        begin
        tmpoword.quit(wdSaveChanges);    tmpoword:=unassigned;
        showmessage('');
      end
      else
     begin
         tmpoword.quit;
         tmpoword:=unassigned;  end;
      

  2.   

    use   TlHelp32, 例子:取word.exe的进程id话 
        AppForceExit('word.exe'); function   AppForceExit(AppName:   string):HWND; 
    var   lppe:   TProcessEntry32; 
            ssHandle:   THandle; 
            AppFound:   Boolean; 
            Wnd:   HWND; 
    begin 
        ssHandle   :=   CreateToolHelp32SnapShot(TH32CS_SNAPALL,   0); 
        lppe.dwSize   :=   SizeOf(lppe); 
        AppFound   :=   Process32First(sshandle,   lppe); 
        wnd:=-1; 
        while   AppFound   do 
        begin 
            
            if   UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AppName)   then 
            begin 
                Wnd   :=   OpenProcess(PROCESS_ALL_ACCESS,   true,   lppe.th32ProcessID); 
                break; 
            end; 
            AppFound   :=   Process32Next(ssHandle,   lppe); 
        end; 
        result:=wnd; 
    end; 返回不是-1表示程序在运行,否则就表示它退出了
      

  3.   

    这样子把正打开的关闭,可巳关闭的WORD文档就无法释放掉变量tmpoword  variant 
      

  4.   

    use   TlHelp32, 例子:关闭'word.exe'的话 
        AppForceExit('word.exe'); procedure   AppForceExit(AppName:   string); 
    var   lppe:   TProcessEntry32; 
            ssHandle:   THandle; 
            AppFound:   Boolean; 
            Wnd:   HWND; 
    begin 
        ssHandle   :=   CreateToolHelp32SnapShot(TH32CS_SNAPALL,   0); 
        lppe.dwSize   :=   SizeOf(lppe); 
        AppFound   :=   Process32First(sshandle,   lppe); 
        while   AppFound   do 
        begin 
            
            if   UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AppName)   then 
            begin 
                Wnd   :=   OpenProcess(PROCESS_ALL_ACCESS,   true,   lppe.th32ProcessID); 
                TerminateProcess(Wnd,   0); 
            end; 
            AppFound   :=   Process32Next(ssHandle,   lppe); 
        end; 
    end;
      

  5.   

    这样子会不会把所有的WORD都关闭呢?
      

  6.   

    var 
        hd:   THandle; begin 
                        Hd   :=   FindWindow   ('OpusApp',nil); 
                        if   Hd   >   0   then 
                            showmessage('已打开Word') 
                        else 
                            showmessage('没有打开Word');
    这样用其应用程序标题如何获得????
      

  7.   

    巳解决,谢谢各位,方法就是FINDWINDOW就行了,刚才把相应的参数位置换了一下就行了.结帖,谢谢大家的关注......