Delphi beginners

Moderators: netgert
Number of threads: 352
Number of posts: 975

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
shellexecute using ini file Posted by arsa on 13 Jun 2008 at 6:12 AM
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
Report
Re: shellexecute using ini file Posted by zibadian on 13 Jun 2008 at 9:22 AM
: 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:
  ShellExecute(Handle, 'open', PChar(pFile), nil, nil, SW_SHOWNORMAL);
Report
Re: shellexecute using ini file Posted by arsa on 17 Jun 2008 at 1:20 AM
: : 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:
:
: 
:   ShellExecute(Handle, 'open', PChar(pFile), nil, nil, SW_SHOWNORMAL);
: 
:

THANK YOU !!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.