我只是想知道这里是否有人知道如何编写代码如何检查项目是否为图像,然后使用 Windows 图像预览打开,否则使用媒体播放器中的构建打开。
代码是这样的:
private bool listbox3job()
{
AxWMPLib.AxWindowsMediaPlayer axWmp = wfh.Child as AxWMPLib.AxWindowsMediaPlayer;
WMPLib.IWMPPlaylist playlist = axWmp.newPlaylist("myPlaylist", string.Empty);
DateTime? start = starttid2.Value;
DateTime? end = sluttid2.Value;
DateTime now = DateTime.Now;
if (start == null || end == null)
{
return false;
}
else if (now >= start.Value && now <= end.Value)
{
foreach (var selected in listBox3.Items)
{
string s = selected.ToString();
if (listBox3Dict.ContainsKey(s))
{
if (extentions.Contains(System.IO.Path.GetExtension(s).ToUpperInvariant()))
{
Process process = new Process();
process.StartInfo.FileName = "rundll32.exe";
process.StartInfo.Arguments = @"C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen " + listBox3Dict[s];
process.Start();
Thread.Sleep(7000);
{
exit();
}
}
else
{
WMPLib.IWMPMedia temp = axWmp.newMedia(listBox3Dict[s]);
playlist.appendItem(temp);
axWmp.settings.setMode("loop", true);
axWmp.settings.autoStart = true;
axWmp.currentPlaylist = playlist;
}
}
}
return true;
}
return false;
}