Ver Mensaje Individual
  #1  
Antiguo 29-01-2008
MON___ MON___ is offline
Miembro
 
Registrado: abr 2007
Ubicación: Salamanca (España)
Posts: 84
Reputación: 18
MON___ Va por buen camino
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?

Última edición por MON___ fecha: 29-01-2008 a las 14:34:46.
Responder Con Cita