zoukankan      html  css  js  c++  java
  • PB调用C# Windows窗体

    以下是PB中的代码:
    String ls_filename
    Long ll_wstyle=1
    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="";  

  • 相关阅读:
    鼠标的移动触发函数改变字体颜色
    Godaddy创始人:成就亿万富翁的10条规则
    关于编程,大学没有传授的十件事
    Using XAMPP for Local WordPress Theme Development
    100+ Resources for Web Developer
    你必须非常努力,才能看起来毫不费力
    建立WordPress博客网站——个人教程
    函数指针和指针函数
    每天写出好代码的5个建议
    LumiSoft Mail Server
  • 原文地址:https://www.cnblogs.com/Veky/p/3254092.html
Copyright © 2011-2022 走看看