配置从C#* .SCR文件 [英] Configure *.scr file from C#

查看:203
本文介绍了配置从C#* .SCR文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的C#.NET程序,的特点之一允许用户从一个列表中,要么预览选择屏幕保护程序或配置。之后做一些研究,我发现,通过调用带有/ C参数将显示配置对话框的* .SCR文件。

I am creating a program in C#.Net, one of the features allows a user to select a screensaver from a list and either preview or configure it. After doing some research I found that by calling the *.scr file with the "/c" argument will display the configuration dialog.

在命令行中使用的作品这种说法罚款(C:\Windows\System32> PhotoScreensaver.scr / C)。但是调用这个从C#总是会导致屏幕被简单地显示为虽然参数只是被忽略

Using this argument from the command line works fine ("C:\Windows\System32>PhotoScreensaver.scr /c") but calling this from C# will always result in the screensaver being simply displayed as though the argument is just being ignored.

我使用的代码是这样的:

The code I am using is this:

Process.Start(ScreensaverPath, "/c");

其中ScreensaverPath包含路径(并包括)* .SCR文件。

where ScreensaverPath contains the path to (and including) the *.scr file.

我也试过这个代码,但无济于事:

I have also tried this code but to no avail:

Process.Start(ScreensaverPath + "/c");



任何帮助将不胜感激。

Any help would be greatly appreciated.

PS我使用Windows 8专业版,但我需要的解决方案是兼容XP和更新的。

P.S. I am using Windows 8 Pro but I need the solution to be compatible with XP and newer.

推荐答案

我不认为通过ARGS将直接从C#工作。如果您键入 C:\windows\system32\sspipes.scr / C 进入开始|运行中,这也将只是直奔屏幕保护程序和不带了配置屏幕。

I don't think that passing args directly will work from C#. If you type c:\windows\system32\sspipes.scr /cinto the Start|Run box, this will also just go straight to the screensaver and not bring up the config screen.

我已经能够通过一个cmd文件做然而,这样的解决方案(虽然不完美)的某处有创建一个cmd文件一行%1 / C

I have been able to do it via a cmd file however, so a solution (albeit not perfect) is to create a cmd file somewhere that has a single line %1 /c

然后就可以传递给CMD文件屏保的路径和文件名这将弹出配置屏幕

Then you can pass the path and filename of the screensaver to the cmd file and this will bring up the config screen

一些快速和肮脏的VB代码将说明

Some quick and dirty VB code will illustrate

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim path As String = "C:\temp\scr.cmd"

        Dim args As String = "C:\WINDOWS\system32\sspipes.scr"

        Dim psi As New ProcessStartInfo
        psi.Arguments = args
        psi.FileName = path
        Process.Start(psi)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim app As String = "C:\WINDOWS\system32\sspipes.scr"
        Process.Start(app)

    End Sub
End Class

这是与2个按钮的形式。 Button1的调出配置的屏幕和按键2运行屏幕保护程序。很明显,你会删除硬编码等所以请原谅坏的编码风格。

This is for a form with 2 buttons. Button1 brings up the config screen and Button 2 runs the screensaver. Obviously you would remove hardcoding, etc so please excuse the bad coding style.

您只需要创建一个名为%scr.cmd一个文本文件1 / C 中,并将其保存到 C:\temp

You just need to create a text file called scr.cmd with %1 /c in it and save it to c:\temp

这篇关于配置从C#* .SCR文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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