shellexecute using ini file

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

  • : 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
    :
    Convert the string to a PChar using type casting:
    [code]
    ShellExecute(Handle, 'open', PChar(pFile), nil, nil, SW_SHOWNORMAL);
    [/code]
  • : : 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
    : :
    : Convert the string to a PChar using type casting:
    : [code]:
    : ShellExecute(Handle, 'open', PChar(pFile), nil, nil, SW_SHOWNORMAL);
    : [/code]:

    THANK YOU !!!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion