PDA

Ver la Versión Completa : De un edit a un string


jorgegetafe
06-06-2007, 11:10:17
Hola tengo un edit (edit1) y quiero que lo que se escriba dentro pase a ser string para utilizar este código:

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 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

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:


... 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.