IDL+C#三种调用方式

       一. IDLDrawWidget 控件(可视化界面)

        1. 新建Windows应用程序,添加IDLDrawWidget控件到环境,拖拽至程序界面。

        2.  触发事件中添加代码:

            int n;
            
this.axIDLDrawWidget1.IdlPath = @"D:\Program Files\ITT\IDL71\bin\bin.x86\i             dl.dll";
            n 
= axIDLDrawWidget1.InitIDL((int)this.Handle);
            
if (n == 0)
            {
                MessageBox.Show(
"IDL 控件初始化失败");
            }
            axIDLDrawWidget1.SetOutputWnd((
int)richTextBox1.Handle);
            
string d = "d";
            axIDLDrawWidget1.ExecuteStr(
"restore,'satstretch.sav'");
            axIDLDrawWidget1.ExecuteStr(
"d=satstretch()");
            
string str = axIDLDrawWidget1.GetNamedData(d).ToString();

            //其中,str 接收程序返回值。

         注: IDL 自 6.3 后就不再更新该控件,需要手动加入IDL的bin目录下几个文件到VS程序执行目录:    pe_core.dll、pe_fact.dll、NCSEcw.dll、hd423m.dll、hm423m.dll 

 

        二、COM_IDL_connect  组件

        1、新建VS程序,添加COM_IDL_connect组件

        2、触发事件中添加代码:

            COM_IDL_connectClass COM = new COM_IDL_connectClass();
            COM.CreateObject(
000);
            
string app=Application.StartupPath;
            COM.ExecuteString(
".COMPILE "+app+"\\satstretch.pro");
            COM.ExecuteString(
"d=satstretch()");
            
string str = COM.GetIDLVariable(d).ToString();


      三、通过IDLEXBR_ASSISTANT输出程序DLL调用

      1、IDL命令行输入 IDLEXBR_ASSISTANT,弹出:Export Bridge Assitant,  按照IDL帮助文档设置好函数和变量属性。

      2、 cmd命令注册组件:regsvr32  组件.dll

      3、 新建VS程序,添加组件.dll。

      4、触发事件添加代码:

            string d = "d";
            satstretchClass SSH 
= new satstretchClass();
            SSH.CreateObject(
000);
            
string app = Application.StartupPath;
            SSH.ExecuteString(
".COMPILE " + app + "\\satstretch.pro");
            SSH.ExecuteString(
"d=satstretch()");
            
string str = SSH.GetIDLVariable(d).ToString();

原文地址:https://www.cnblogs.com/henyihanwobushi/p/2982509.html