通过单击picturebox1 c#在Windows照片查看器中打开图像 [英] open the image in windows photo viewer by clicking on picturebox1 c#

查看:1675
本文介绍了通过单击picturebox1 c#在Windows照片查看器中打开图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有SQlite数据库的项目。我将图像保存在pics文件夹中(进入调试文件夹)&他们在数据库中的名称(列docpic)。当我连续点击时,相关图像将图像从数据库检索到picturebox1。我想通过点击picturebox1打开windows photo viewer打开图像(在picturebox1中)。
怎么办呢?

I have a project with SQlite database . I save images in folder " pics " ( into debug folder) & their name in the database ( column "docpic") . When I click in a row , related image retrieve the image from database to picturebox1 . i want open the image ( in picturebox1 ) by windows photo viewer by clicking on picturebox1 . how can do this ?

我在picturebox1点击事件中使用这些代码,但这不起作用:

i use this codes in picturebox1 click event but thats not work :

if (pictureBox1.Tag != null)
{
    System.Diagnostics.Process imageViewerProcess = new System.Diagnostics.Process();
    imageViewerProcess.StartInfo.CreateNoWindow = false;
    imageViewerProcess.StartInfo.FileName = "rundll32.exe";
    imageViewerProcess.StartInfo.Arguments =
            @"C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen "
                               + pictureBox1.Tag.ToString();
    imageViewerProcess.Start();
}

}

推荐答案

你在参数中遗漏了一些东西,因为它必须有正确的路径

如果你使用的是Windows 7 64位,那么改变
C:\ Windows\system32 到你的参数代码行中的 C:\ Windows \SysWOW64
所以它变成:

you missing something in the argument , because it must have the correct path
and if you are using Windows 7 64-bit then change
C:\Windows\system32 to C:\Windows\SysWOW64 inside your argument code line .
so it become :

imageViewerProcess.StartInfo.Arguments = 
      @"C:\Windows\SysWOW64\shimgvw.dll,ImageView_Fullscreen "+ pictureBox1.Tag.ToString();






相反


and instead of all your code you can shortly use :


  • 简单使用:

System.Diagnostics.Process.Start(@"Directory + image name");





  • 用于高级用法:

    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(){
                    FileName  = @"Directory + image name",
                    UseShellExecute = true,
                    Verb  = "open"
                   });
    





  • 另一种方式:

    ProcessStartInfo startInfo = new ProcessStartInfo(@"Directory + image name");
                                 startInfo.Verb = "open";
                                 System.Diagnostics.Process.Start(startInfo);
    





  • and ofcourse改变这个:目录+图像名称到您的图像路径。

    and ofcourse change this: "Directory + image name" to your image path.


    • 注意:必须是完整路径

           ;      例如: c:\ folder\image.jpg

                ;  而不仅仅是 image.jpg

    • Note: its necessary to be complete path
                 example : c:\folder\image.jpg ,
                 and not just image.jpg

    这篇关于通过单击picturebox1 c#在Windows照片查看器中打开图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆