简体   繁体   English

Visual Basic 关闭程序

[英]Visual basic closing a program

I have a really simple question, or at least I think it should be as simple as it can gets... I'm opening a jpg file by the simple statement:我有一个非常简单的问题,或者至少我认为它应该尽可能简单......我通过简单的语句打开一个 jpg 文件:

Process.Start(PlatiBild) Process.Start(PlatiBild)

Where the variable "PlatiBild" just indicates the path and filename.其中变量“PlatiBild”仅表示路径和文件名。 The default program by which this file is opened is "Pictures" from Microsoft itself.打开此文件的默认程序是 Microsoft 本身的“图片”。 This works just fine.这工作得很好。

Now I want to close this file when a condition is met, but here is my problem.现在我想在满足条件时关闭这个文件,但这是我的问题。 It just won't work.它只是行不通。

There is no such thing like: Process.Close(PlatiBild)没有这样的东西: Process.Close(PlatiBild)

So I tried for example: Process.GetProcessesByName("Pictures")(0).Kill()所以我尝试了例如: Process.GetProcessesByName("Pictures")(0).Kill()

But still, the Pictures app just wont close.但是,图片应用程序仍然不会关闭。 In my opinion it should be just one simple line of code, am I wrong?在我看来,它应该只是一行简单的代码,我错了吗?

Thanks to everyone who at least takes a look at this!感谢所有至少看过这个的人!

I just found out by myself and of course by your comments, that to close the Photos App from Microsoft you need to call the following:我刚刚自己发现,当然还有您的评论,要关闭 Microsoft 的照片应用程序,您需要调用以下命令:

Process.GetProcessesByName("Microsoft.Photos")(0).Kill() Process.GetProcessesByName("Microsoft.Photos")(0).Kill()

So you actually have to call 'Microsoft.Photos' and not just 'Photos' as indicated in the Process names of the Taskmanager.因此,您实际上必须调用“Microsoft.Photos”,而不仅仅是任务管理器的进程名称中指示的“照片”。

Also as minimalist mentioned you need to kill, as it looks like that the statement CloseMainWindow() doesn't work for this application!同样正如极简主义者提到的那样,您需要杀死,因为看起来 CloseMainWindow() 语句不适用于此应用程序!

Thanks to everyone who took time to watch at this issue!感谢所有花时间观看此问题的人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM