Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.FileName = "C:\Program Files (x86)\IrfanView\i_view32.exe"
myProcess.StartInfo.Arguments = sFileName
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()
当文件位于本地驱动器上时,上面在 Irfanview 中打开 tif 图像的代码可以完美运行。如果文件在网络共享上,Irfanview 将在标题栏中显示为挂起(未响应)。这是 Windows 7 的新行为。在同一网络上的 Windows XP 机器上,我没有这个问题。
知道为什么吗?
格雷格
[编辑]
我还尝试了下面的代码,但没有成功,并尝试了 irfanview 旁边的另一个图像查看器并得到了相同的结果。使用此代码 irfanview 告诉我它不是有效文件,并显示文件的确切路径和文件名。很烦人。旧的 Windows API ShellExecute 不会启动程序。呸呸呸!!!
Dim domain As String = {domain}
Dim uname As String = {username}
Dim passwordtx As String = {password}
Dim password As New System.Security.SecureString()
Dim c As Char
For Each c In passwordtx
password.AppendChar(c)
Next c
Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.FileName = "C:\Program Files (x86)\IrfanView\i_view32.exe"
myProcess.StartInfo.Arguments = sFileName
myProcess.StartInfo.WorkingDirectory = "C:\"
myProcess.StartInfo.UserName = uname
myProcess.StartInfo.Domain = domain
myProcess.StartInfo.Password = password
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()