• 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="";  

  • 相关阅读:
    一文说清 InnoDB 的事务机制
    MySQL 索引结构
    Mysql索引(一篇就够le)
    对Elasticsearch生命周期的思考
    elasticsearch备份和还原(基于hdfs)
    想写一篇jvm的工具入门
    elasticsearch跨集群数据迁移
    [论文阅读]阿里DIN深度兴趣网络之总体解读
    [源码阅读] 阿里SOFA服务注册中心MetaServer(3)
    [源码阅读] 阿里SOFA服务注册中心MetaServer(2)
  • 原文地址:https://www.cnblogs.com/Veky/p/3254092.html
Copyright © 2020-2023  润新知