
正文
vb.net程序所在 vbnet using
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net运行所在目录的应用程序并加参数
可试试下面的方法:
1.可接收参数的外部程序
/// summary
/// 可接收参数的外部程序主函数
/// /summary
static class Program
{
/// summary
/// The main entry point for the application.
/// /summary
[STAThread]
static void Main(string[] paras)
{
string temp = "";
foreach (string str in paras)
{
temp += str + ",";
}
MessageBox.Show(temp);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
2.启动外部程序的方法(给外部程序加参数)
/// summary
/// 调用外部程序窗体
/// /summary
public partial class Invokeprogram : Form
{
public Invokeprogram()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.FileName = Application.StartupPath + "\\WindowsFormsApplication1.exe";
proc.StartInfo.Arguments = "-steam -game cstrike"; //传入启动参数
proc.Start();
//string output = proc.StandardOutput.ReadToEnd();
// MessageBox.Show(output);
}
}
相关问答
Q1: VB.NET中怎么找到EXE程序所在的路径
见上图,用鼠标按照上述三个步骤先后次序,一一单击进行选择和设置,“生成输出路径”。
那么,在你的程序代码里使用:
MsgBox(Application.StartupPath)
显示的就是,你的当前默认的相对路径。
也可以按照自己的需要重新设置该路径。
Q2: 如何获取VB.NET窗体所在路径
1、如果你的窗体就是你当前工程这个EXE本身的窗体,
那么窗体所在的路径就是工程的启动路径,用下面的语句获取:
AppPath=Application.StartupPath
2、如果你的窗体是你自己LoadLibrary的某个DLL的窗体,那么你既然能LoadLibrary,就应该知道它的路径,所以不用问了。
Q3: VB中如何获取当前程序的绝对路径
System.Environment.CurrentDirectory;
//例: c:/test/
Application.ExecutablePath;(包括名称)
//例: c:/test/myapp.exe
Application.StartupPath;(不包括名称)
//例: c:/test/
绝对路径是直接到达目标位置,通常是从盘符开始的路径。完整的描述文件位置的路径就是绝对路径,以web站点根目录为参考基础的目录路径。
绝对路径名的指定是从树型目录结构顶部的根目录开始到某个目录或文件的路径,由一系列连续的目录组成,中间用斜线分隔,直到要指定的目录或文件,路径中的最后一个名称即为要指向的目录或文件。之所以称为绝对,意指当所有网页引用同一个文件时,所使用的路径都是一样的。
扩展资料
几种编程语言获取程序所在路径的方法:
1、在golang程序里面获取程序所在路径:
package main
import (
"path/filepath"
"os"
"fmt"
"log"
)
func main() {
execDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err = nil {
log.Fatal(err)
}fmt.Println(execDir)
}
2、python脚本所在路径:
import os
print(os.path.split(os.path.realpath(__file__))[0])
3、shell脚本获取脚本的绝对路径:
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" pwd )"
关于vb.net程序所在和vbnet using的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






