Entwickler-Ecke

Dateizugriff - C++ DLL Funktionsaufruf / Übergabe WCHAR_T -> ERROR EZeroDev


peeage - So 17.08.08 17:11
Titel: C++ DLL Funktionsaufruf / Übergabe WCHAR_T -> ERROR EZeroDev
Hallo Zusammen..

Habe hier eine C++ DLL welche ich in meinem Programm nutzen möchte. Diese DLL beinhaltet eine Funktion mit folgendem Aufruf:


C#-Quelltext
1:
SWIrecFuncResult SWIrecInit ( const wchar_t *path );                    



Ich habe das in Delphi folgender Maßen umgesetzt:


Delphi-Quelltext
1:
function SWIrecInit( const pPath: PWideChar ) : Integer; CDECLExternal 'SWIrec.dll';                    



... laut Herstellerdoku kann man als pPath auch NULL ( in Delphi NIL ) übergeben. Wenn ich die Funktion nun folgendermaßen aufrufe:


Delphi-Quelltext
1:
SWIrecInit( nil );                    


... bekomm ich die Fehlermeldung: EZeroDevide (Gleitkommadivision durch Null ).

Der Debugger hängt auf folgender Zeile fest:

fstp dword ptr [esi+eax*4]




Hat irgendeiner Ahnung ob ich etwas falsch mache?


Gruß, Martin


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 17.08.2008 um 23:01


MSCH - Sa 30.08.08 15:09

ohne quelltext der Bibliothek ein recht aussichtloses unterfangen.
Es sei denn, du kennst dich mit einem (dis-)assembler aus.
Msch


Mario1988 - Fr 02.09.11 16:40

perhaps it is late for you, but my answer could be useful for somebody else facing the same problem.

To day I had the divide by zero exception, invoking method SWIrecInit belonging to the dll SWIrec.dll (ver. 9.0.3.7353) with Borland C++ builder 6.

Using Microsoft VC++ 6 the problem does not appear but simply because Microsoft compiler suppresses the exception

The only way I had to make it work with Borland was to suppress the exception in the following way.


C#-Quelltext
1:
2:
3:
4:
5:
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
_control87(MCW_EM, MCW_EM);
}

don't forget to include float.h

regards

Moderiert von user profile iconNarses: C#-Tags hinzugefügt