gpt4 book ai didi

c# - 如何从 C# 启动 windows "run"对话框

转载 作者:可可西里 更新时间:2023-11-01 12:42:38 26 4
gpt4 key购买 nike

我想在我的 C# 代码中从 Windows 启动运行对话框 (Windows+R)。

我认为这可以使用 explorer.exe 来完成,但我不确定如何做。

最佳答案

使用 RunFileDlg:

[DllImport("shell32.dll", EntryPoint = "#61", CharSet = CharSet.Unicode)]
public static extern int RunFileDlg(
[In] IntPtr hWnd,
[In] IntPtr icon,
[In] string path,
[In] string title,
[In] string prompt,
[In] uint flags);

private static void Main(string[] args)
{
// You might also want to add title, window handle...etc.
RunFileDlg(IntPtr.Zero, IntPtr.Zero, null, null, null, 0);
}

flags 的可能值:

RFF_NOBROWSE = 1; //Removes the browse button.
RFF_NODEFAULT = 2; // No default item selected.
RFF_CALCDIRECTORY = 4; // Calculates the working directory from the file name.
RFF_NOLABEL = 8; // Removes the edit box label.
RFF_NOSEPARATEMEM = 14; // Removes the Separate Memory Space check box (Windows NT only).

另见 How to programmatically open Run c++?

关于c# - 如何从 C# 启动 windows "run"对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9331088/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com