I am new in delphi and I need some help, what is wrong in tis code
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShellApi, IniFiles;
var Handle: hwnd;
IniFile: TIniFile;
pFile: string;
begin
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'vinco.ini');
pFile := IniFile.ReadString('SYS', 'DATADIR', 'd:vinco');
ShellExecute(Handle, 'open', pFile, nil, nil, SW_SHOWNORMAL);
end.
I have error report
[Pascal Error] vinco.dpr(18): E2010 Incompatible types: 'string' and 'PAnsiChar'
What shell I do ? Please
Comments
:
: uses
: Windows, Messages, SysUtils, Variants, Classes, Graphics,
: Controls, Forms, Dialogs, ShellApi, IniFiles;
:
: var Handle: hwnd;
: IniFile: TIniFile;
: pFile: string;
:
: begin
: IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) +
: 'vinco.ini');
: pFile := IniFile.ReadString('SYS', 'DATADIR', 'd:vinco');
: ShellExecute(Handle, 'open', pFile, nil, nil, SW_SHOWNORMAL);
: end.
:
: I have error report
:
: [Pascal Error] vinco.dpr(18): E2010 Incompatible types: 'string' and
: 'PAnsiChar'
:
: What shell I do ? Please
:
Convert the string to a PChar using type casting:
[code]
ShellExecute(Handle, 'open', PChar(pFile), nil, nil, SW_SHOWNORMAL);
[/code]
: :
: : uses
: : Windows, Messages, SysUtils, Variants, Classes, Graphics,
: : Controls, Forms, Dialogs, ShellApi, IniFiles;
: :
: : var Handle: hwnd;
: : IniFile: TIniFile;
: : pFile: string;
: :
: : begin
: : IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) +
: : 'vinco.ini');
: : pFile := IniFile.ReadString('SYS', 'DATADIR', 'd:vinco');
: : ShellExecute(Handle, 'open', pFile, nil, nil, SW_SHOWNORMAL);
: : end.
: :
: : I have error report
: :
: : [Pascal Error] vinco.dpr(18): E2010 Incompatible types: 'string' and
: : 'PAnsiChar'
: :
: : What shell I do ? Please
: :
: Convert the string to a PChar using type casting:
: [code]:
: ShellExecute(Handle, 'open', PChar(pFile), nil, nil, SW_SHOWNORMAL);
: [/code]:
THANK YOU !!!