PB调用C# Windows窗体

以下是PB中的代码:

String ls_filename

Long ll_wfont: normal 14px / 24px Helvetica, Tahoma, Arial, sans-serif; color: rgba(51, 51, 51, 1); text-transform: none; text-indent: 0; letter-spacing: normal; word-spacing: 0; white-space: normal; orphans: 2; widows: 2; font-size-adjust: none; background-color: rgba(245, 245, 245, 1); -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> long ll_hwnd,ll_nShowCmd

string ls_lpOperation,ls_lpFile,ls_lpParameters,ls_lpDirectory

ll_hwnd=handle(w_main)

ls_lpOperation="open"

ls_lpFile="CPRM.exe"

ls_lpParameters="aaaaaaaaa"

ls_lpDirectory=""

ll_nShowCmd=1 //3最大化

ShellExecute(ll_hwnd,ls_lpOperation,ls_lpFile,ls_lpParameters,ls_lpDirectory,ll_nShowCmd)

C#:

在Program.cs中,原有的Main函数是这样的:

view plaincopy to clipboardprint?

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

将其改为:

view plaincopy to clipboardprint?

static void Main(string[] args)

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

if (args.Length == 1)

Application.Run(new Form1(args[0]));

else Application.Run(new Form1());

}

即可接收参数的传递,上面的代码只对参数数目为1的情况进行了判断及处理,有其它需求也可以做类似的处理,由于上面调用了Form1的两种构造函数,那么还需要对Form1的构造函数进行重写:

view plaincopy to clipboardprint?

public Form1()

{

InitializeComponent();

}

public Form1(string cmdArg)

{

testString = cmdArg;

InitializeComponent();

}

private string testString="";