bbonik 0 Newbie Poster

Dear all,
I am new in using Borland C++ and I face a difficult problem to solve. I would be most grateful if you gave me some advice on it. I use Borland builder 6, with winXP+SP3

I have created a dll (mydll.dll) which opens a binary file, makes some processing and then saves the file in another location. The compilation of the dll was successful and has given no warnings or any problems at all.

I have also created a very simple application just to test the calling of the dll (just one button + one open dialog to give the location of the binary file). The code of this simple application is the following:

#include <vcl.h>
#include <string.h>
#include <windows.h>
#include "Unit1.h"
#pragma hdrstop
#pragma package(smart_init)
#pragma resource "*.dfm"

extern "C" __declspec(dllimport) void mydll(int P1, int P2, AnsiString P3, double P4, double P5, double P6, double P7, double P8);

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        int P1,P2;
        AnsiString P3;
        double P4, P5, P6, P7, P8;

         //getting the input values
                P1 = 2816;
		P2 = 3584;
		P4 = 50;
		P5 = 0;
		P6 = 1;
		P7 = 70;
		P8 = 100;

        if( OpenDialog1->Execute() == True )
	{
                    P3=OpenDialog1->FileName;
                }

        mydll(P1, P2, P3, P4, P5, P6, P7, P8);
}

If I press the button, the open dialog box opens and after I give the filename, the dll is called, the processing is successfully done and the new file is saved also successfully. HOWEVER, if I close the application (press the X button) I get the following error:

“Runtime Error 204 at 40002FFC”

I tried everything I currently know and I couldn’t correct the problem.

Some extra information:
1. If I omit the calling of the dll in the simple application (line: mydll(P1, P2, P3, P4, P5, P6, P7, P8);) there is no problem: I press the X button of the application and the window closes without a problem.
2. I also embedded the source code of the dll inside the code of the simple application (instead of calling the dll, I performed all the processing of the dll in the application) and there was also no problem at all.

Do you have any ideas of what might be wrong?

Thank you in advance,

bbonik

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.