0

dll をインポートし、その関数を数回呼び出すコードがあります。特定の入力に対して dll 関数が例外をスローしていますが、他の入力に対しては正常に動作します。ここでdllの例外について少し調べた後 、単純なアプローチでdllの場合、ランタイム例外は処理されないようです。

これが私のコードです

int main( void ) 
{ 
    WORD_DATABASE wd=parse_data();

    const char* WorkingDirPath="C:\\Users\\Koustav\\Dropbox\\Project\\July07_PT
    int UserID=1;
    DEVICE_INFO_T test= TOP_LEFT;

    HINSTANCE hinstLib; 
    //    MYPROC ProcAdd; 
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 

    // Get a handle to the DLL module.

    hinstLib = LoadLibrary(TEXT("Recog_Malayalam.dll"));
    // If the handle is valid, try to get the function address.pppppp

    if (hinstLib != NULL)


    { 



    f_funci init = (f_funci)GetProcAddress(hinstLib,"abc");
    f_funci1 reco = (f_funci1)GetProcAddress(hinstLib,"xyz");
    // If the function address is valid, call the function.

    int a = init(WorkingDirPath,1,(DEVICE_INFO_T)1);


    for (int c3=0;c3<120;c3++)
    {   
        try{
            "<<wd.annotation_detail[c3].uni_val<<endl;
            for (int c4=0;c4<wd.annotation_detail[c3].stroke_count;c4++)
            {
                log_cl<<wd.annotation_detail[c3].stroke_labels[c4]-1<<" ";
            }
            log_cl<<"Actual Values"<<endl;
            cout<<endl;
            //cout<<"Supplied stroke label"<<wd.annotation_detail[c3].stroke_labels[0]<<endl;
            int b=0;
            try{
                b = reco(wd.word_db[c3],wd.annotation_detail[c3].stroke_count,PLAIN,0,'\0',1);
            }
            catch(exception e){
                b=0;
                cout<<"try_catch_success"<<endl;
            }
            //cout<<"Supplied stroke label"<<wd.annotation_detail[c3].stroke_labels[0]<<endl;
            cout<<endl;


        }




        catch(exception e){
            cout<<"There is an exception"<<endl;
        }
    }
    fFreeResult = FreeLibrary(hinstLib); 


} 


// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess) 


    getch();
return 0;

}

私はdllでもtry catchブロックを使用しました。エラーは、複数回呼び出される 2 番目の関数から発生しています。

hereおよびhereに記載されているように、プロジェクトのプロパティを変更しました。しかし、私はまだこのエラーが発生しています。(dll を作成するプロジェクトのプロパティと、dll を呼び出すプロジェクトのプロパティを変更しました)

エラー

dll にアクセスできないと仮定すると、どうすればこのコードを修正できますか? 無理ならdllにアクセスできれば可能でしょうか?

どんな助けでも大歓迎です

4

1 に答える 1

2

try-catch は例外用です。このダイアログ ボックスはアサーション用です。事実上無関係な異なる獣。

于 2013-09-18T14:00:13.347 に答える