Solved

How can i use Winexc or ShellExecute to work with inifiles

Posted on 1998-10-12
5
388 Views
Last Modified: 2010-04-06
How can i use Winexc or ShellExecute to work with inifiles, I want to import a windows registry file by via inifile. How can i get this code to do that.

Regini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Install.ini');
Winexec(PChar('Regedit'+Regini.ReadString('options','blah','')), SW_SHOW);
or
Regini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Install.ini');
ShellExecute(Handle, 'Open', PChar('Regedit'+ Regini.ReadString('options','blah','')),Nil,Nil, SW_SHOWNORMAL);


0
Comment
Question by:TCSCode
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:ow
Comment Utility
Hi TCSCode,

why don't you use tRegistry to import the ini-data?
I supose, you have to adapt the read ini lines and at least to determine the registry key, where you want to import the data strings.

regards
  ow
0
 
LVL 3

Expert Comment

by:philipleighs
Comment Utility
Hi,

It seems there is a more elegant way of doing what you want (see ow's comment).

However, if you really want to run regedit, then put a ".exe " after regedit.
At the moment your arg looks like:
regedit[blah]
where [blah] is the string in the INI file. I think it should look more like:
regedit.exe [blah]
Note the space in between.

Phil.
PS: I don't want to start a debate about coding practices, but decompacting your code would make debugging easier.

var CommandLine: string;
begin
Regini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Install.ini');
try
  CommandLine := 'RegEdit.exe';
  CommandLine := CommandLine + ' ' +   Regini.ReadString('options','blah','');
  Winexec(PChar(CommandLine, SW_SHOW);
finally
  Regini.Free;
end;
0
 

Author Comment

by:TCSCode
Comment Utility
Hi, Philip Leighs.

  Thank you for replying, the code works great. I tryied to do it that way but kept getting lost, I've only been programming for just a bit over a month, " Any Codeing Tips, I Would Be greatful " anyways Thank you both for you input Ow and Philip.

 P.S. Philip you need to Proposed a answer so i can give your points for this answer already given. Thank's again. TCSCode.

0
 
LVL 3

Accepted Solution

by:
philipleighs earned 100 total points
Comment Utility
Hi TSCCode,

Glad to help.

Cheers,
Phil.

0
 

Author Comment

by:TCSCode
Comment Utility
Thanks again.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now