Solved

How can i use Winexc or ShellExecute to work with inifiles

Posted on 1998-10-12
5
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:ow
ID: 1342593
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
ID: 1342594
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
ID: 1342595
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
ID: 1342596
Hi TSCCode,

Glad to help.

Cheers,
Phil.

0
 

Author Comment

by:TCSCode
ID: 1342597
Thanks again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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