这个可能要用到系统的API:OpenFile了
具体的我没实践过
GZ
具体的我没实践过
GZ
解决方案 »
- crystalReportViewer+ReceiveCrystalReport.rpt+DataSet.xsd做报表
- 连接数据库
- 在sql server中增加一列后,在C#中访问不到
- C# Winform中的textbox控件回车事件疑问。
- 如何实现用OpenFileDialog获取的路径显示到旁边的TextBox中显示FileName
- 寻找C#语法帮助.chm文件...Thank you !
- 如何让DataGrid里面的列不自动排序?
- [求助]用axWebBrowser控件开发浏览器,请问怎样实现改变编码和字体大小?
- 如何把登陆用户的用户名传到发帖页面??????
- c#的学习
- 初次接触c#,给点.........
- 100分小问题?
{
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();
}
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
{
/// <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
);
}
// 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);
---------------------------
似乎是没有返回值的
用判断进程的方法吧
我输入了正确的密码,进去之后,也没有产生其它特别的进程吧?
我输入了正确的密码,进去之后,也没有产生其它特别的进程吧?
{
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;
}