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();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM