这个可能要用到系统的API:OpenFile了
具体的我没实践过
GZ

解决方案 »

  1.   

    不是的,那肉眼也能看出来呢~我是想要程序判断,再执行相关的操作。private void btnBeginCrack_Click(object sender, System.EventArgs e)
    {
    pass_long=Int16.Parse(nudPasslong.Value.ToString());
    max_num=long.Parse(Math.Pow(10,pass_long).ToString());
    min_num=long.Parse(Math.Pow(10,pass_long-1).ToString());
    flag=0;
    for(k=0;k<pass_long-1;k++)
    {
    max_num=long.Parse(Math.Pow(10,pass_long-k).ToString());
    min_num=long.Parse(Math.Pow(10,pass_long-k-1).ToString());
    for(j=0;j<pass_long-1;j++)
    {
    for(i=(pass_long-k==1?1:min_num);i<max_num;i=i+pass_long)
    {
    pass=StringEx(10,"0")+i.ToString();
    txtCrackStatus.Text=pass;
    txtCrackStatus.Refresh();
    Object filename = strpath;
    Object confirmConversions = Type.Missing;
    Object readOnly = Type.Missing;
    Object addToRecentFiles = Type.Missing;
    Object passwordDocument = Type.Missing;
    Object passwordTemplate = pass;
    Object revert = Type.Missing;
    Object writePasswordDocument = Type.Missing;
    Object writePasswordTemplate = Type.Missing;
    Object format = Type.Missing;
    Object encoding = Type.Missing;
    Object visible = Type.Missing;
    Object openConflictDocument = Type.Missing;
    Object openAndRepair  = Type.Missing;
    Object documentDirection = Type.Missing;
    Object noEncodingDialog = Type.Missing;
    flag=wd.Documents.Open(ref filename, //我想在这里判断Word是否打开。!!
    ref confirmConversions, ref readOnly, ref addToRecentFiles, 
    ref passwordDocument, ref passwordTemplate, ref revert, 
    ref writePasswordDocument, ref writePasswordTemplate, 
    ref format, ref encoding, ref visible, ref openConflictDocument, 
    ref openAndRepair , ref documentDirection, ref noEncodingDialog);
    if(flag!=0)
    {
    lblCrackStatus.Text="密码为:";
    txtCrackStatus.Text=pass;
    wd.Visible=true;
    return;
    }
    }
    }
    }
    MessageBox.Show("密码位数不对,请重新输入。","请重输密码位数");
    txtCrackStatus.Text=max_num.ToString();
    }
      

  2.   

    VB下是这样的,我只是把它改写成C#而已。Private Sub cmdopendoc_Click() 
    Dim wd As New Word.Application 
    Dim strpath As String 
    Dim pass As String 
    Dim J, K, Pass_long As Integer 
    Dim Max_num, Min_num, I As Long 
    strpath = File1.Path & "\" & File1.FileName 
    On Error Resume Next 
    '程序开始 
    Pass_long = Val(Text2.Text) 
    Max_num = 10 ^ Val(Text2.Text) 
    Min_num = 10 ^ (Val(Text2.Text) - 1) 
    Flag = 0 
    For K = 0 To Pass_long - 1 
    Max_num = 10 ^ (Pass_long - K) 
    Min_num = 10 ^ (Pass_long - (K + 1)) 
    For J = 0 To Pass_long - 1 
    cmdopendoc.MousePointer = 11 
    For I = IIf(Pass_long - K = 1, 0, Min_num) + J To Max_num Step Pass_long 
    Text1.Text = pass 
    Text1.Refresh 
    pass = String(K, "0") & I 
    Flag = wd.Documents.Open(FileName:=strpath, passworddocument:=pass) 'VB下是这样的,我只是把它改写成C#而已。
    '如果解密成功,打开文档,显示密码,退出过程 
    If Flag <> 0 Then 
    Label1.Caption = "文档密码" 
    Label1.Refresh 
    Text1.Text = pass 
    wd.Visible = True 
    cmdopendoc.MousePointer = 0 
    Exit Sub 
    End If 
    Next I 
    Next J 
    Next K 
    MsgBox "密码位数不对,请重新输入" 
    End Sub Private Sub cmdquit_Click() 
    End 
    End Sub Private Sub Dir1_Change() 
    File1.Path = Dir1.Path 
    End Sub Private Sub Drive1_Change() 
    Dir1.Path = Drive1.Drive 
    End Sub Private Sub File1_DblClick() 
    Call cmdopendoc_Click 
    End Sub
      

  3.   

    public abstract class OneInstance 

    /// <summary> 
    /// 用来判断一个指定的程序是否正在运行 
    /// </summary> 
    /// <param name="appId">程序名称,长一点比较好,防止有重复</param> 
    /// <returns>如果程序是第一次运行返回True,否则返回False</returns> 
    public static bool IsFirst(string appId) 

    bool ret=false; 
    if(OpenMutex(0x1F0001,0,appId)==IntPtr.Zero) 

    CreateMutex(IntPtr.Zero,0,appId); 
    ret=true; 

    return ret; 
    }  [DllImport("Kernel32.dll",CharSet=CharSet.Auto)] 
    private static extern IntPtr OpenMutex( 
    uint dwDesiredAccess,  // access 
    int bInheritHandle,    // inheritance option 
    string lpName          // object name 
    );  [DllImport("Kernel32.dll",CharSet=CharSet.Auto)] 
    private static extern IntPtr CreateMutex( 
    IntPtr lpMutexAttributes,  // SD 
    int bInitialOwner,                       // initial owner 
    string lpName                            // object name 
    ); 
    }
      

  4.   

    调用API或.NET提供的方法检查WINWORD进行是否存在,存在即打开。
      

  5.   

    MSDN上
    // C#
    object missingValue = Type.Missing; 
    object fileName = "C:\\Test\\MyNewDocument.doc"; 
    word.Application.Documents.Open(ref fileName, ref missingValue, 
        ref missingValue, ref missingValue, ref missingValue,
        ref missingValue, ref missingValue, ref missingValue,
        ref missingValue, ref missingValue, ref missingValue,
        ref missingValue, ref missingValue, ref missingValue,
        ref missingValue, ref missingValue);
    ---------------------------
    似乎是没有返回值的
    用判断进程的方法吧
      

  6.   

    不是的,当我打开WORD时,在没有输入密码的情况下,还是有winword.exe这个进程的啊~~
    我输入了正确的密码,进去之后,也没有产生其它特别的进程吧?
      

  7.   

    不是的,当我打开WORD时,在没有输入密码的情况下,还是有winword.exe这个进程的啊~~
    我输入了正确的密码,进去之后,也没有产生其它特别的进程吧?
      

  8.   

    public static Process RunningInstance()  
    {  
         Process current = Process.GetCurrentProcess(); 
         Process[] processes = Process.GetProcessesByName (current.ProcessName); 
          //Loop through the running processes in with the same name 
     
          foreach (Process process in processes) 
           {  
              //Ignore the current process 
                if (process.Id != current.Id) 
               { 
                    //Make sure that the process is running from the exe file. 
                     if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName) 
                     { 
                         //Return the other process instance. 
                         return process; 
                     } 
                } 
           } 
           //No other instance was found, return null. 
           return null; 
     } 
      

  9.   

    Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName句中的命名空间是什么啊?