Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   De un edit a un string (https://www.clubdelphi.com/foros/showthread.php?t=44433)

jorgegetafe 06-06-2007 11:10:17

De un edit a un string
 
Hola tengo un edit (edit1) y quiero que lo que se escriba dentro pase a ser string para utilizar este código:

Código Delphi [-]
PROCEDURE TForm1.ToolButton40Click(Sender: TObject);
 VAR
  direccion: STRING;
 BEGIN
  direccion:= edit1.Text;
    TRY
      ShellExecute(0, 'open', direccion, NIL, NIL, SW_SHOW)
    Except
      showmessage ('La disquetera no está lista o no tiene disquetera.');
    END;
END;

En la linea
Código Delphi [-]
ShellExecute(0, 'open', direccion, NIL, NIL, SW_SHOW)
me dice que hay tipos incompatibles PAnsirChar (que no se lo que es) con un string.

Una manita porfa. Muchas gracias.

tito_lolo 06-06-2007 11:23:20

Prueba a poner

Código Delphi [-]
ShellExecute(0, 'open', pchar(direccion), NIL, NIL, SW_SHOW);

Lo que hacemos es un cast de string a PAnsirChar.

Un saludo

jorgegetafe 06-06-2007 11:26:32

Funciona, mil gracias. :-)

Neftali [Germán.Estévez] 06-06-2007 11:29:05

Añade:

Código Delphi [-]
...  PChar(direccion)...

Si te hace falta en algun parámetro más le haces lo mismo.

jorgegetafe 06-06-2007 11:31:25

Con eso es suficiente ;-) gracias de todas formas.


La franja horaria es GMT +2. Ahora son las 08:20:53.

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