Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Error "EInvalidPointer" (https://www.clubdelphi.com/foros/showthread.php?t=52714)

MON___ 29-01-2008 14:27:53

Error "EInvalidPointer"
 
Espero haber acertado con la sección, pues mi consulta tiene que ver tanto con DELPHI como con C++ BUILDER.
Se trata de una llamada a una función de una DLL; muestra una ventana con un objeto TListBox; si se pulsa el botón ACEPTAR la función devuelve TRUE y los valores contenidos en el objeto TListBox. Sin embargo la aplicación (en DELPHI) me devuelve la excepción EInvalidPointer.

CÓDIGO DE LA DLL (C++)
Código Delphi [-]
extern "C" _declspec(dllexport) bool _stdcall SeleccionarValores(char *buffer);
bool _stdcall SeleccionarValores(char *buffer){
        bool resultado = FALSE;
        Application->CreateForm(__classid(TFVentana), &FVentana);
        try{
           FVentana->ListBox1->Items->Add("PRIMAVERA");
           FVentana->ListBox1->Items->Add("VERANO");
           FVentana->ListBox1->Items->Add("OTOÑO);
           FVentana->ListBox1->Items->Add("INVIERNO");
           resultado = (FVentana->ShowModal == mrOk);
           if (resultado){
           int x;
           x = SendMessage(FVentana->ListBox1->Handle, WM_GETTEXTLENGTH, 0, 0);
           x++;
           buffer = StrAlloc(x);
           buffer = FVentana->ListBox1->Items->GetText();
           }         }         __finally{
         delete FVentana;
       }        return  resultado; }
CÓDIGO DEL EXE (DELPHI)
Código Delphi [-]
procedure TForm1.Button2Click(Sender: TObject);
  type
    TLlamarDLL = function(buffer : PChar):boolean;stdcall;
  var
    LlamarDLL : TLlamarDLL;
    DLL : THandle;
    buffer : pchar;
 begin 
   DLL := LoadLibrary('LIBRERIA.DLL');
   if DLL > 0 then
    begin
     @LlamarDLL := GetProcAddress(DLL, 'SeleccionarValores');
    if not(@LlamarDLL = nil) then     
    begin         
        LlamarDLL(buffer);         
// Los valores que se mostraban en el LISTBOX de la DLL los "guardo" en el TCOMBOBOX de la aplicación
        ComboBox1.Items.SetText(buffer);
        StrDispose(buffer);
    end;
   FreeLibrary(DLL);
   end;
end;

¿Me podéis explicar dónde está el error?


La franja horaria es GMT +2. Ahora son las 22:52:33.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi