shellexecute using ini file - Programmers Heaven

Howdy, Stranger!

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

Categories

shellexecute using ini file

arsaarsa Posts: 2Member
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

  • zibadianzibadian Posts: 6,349Member
    : 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]
  • arsaarsa Posts: 2Member
    : : 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.