[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can i use Winexc or ShellExecute to work with inifiles

Posted on 1998-10-12
5
Medium Priority
?
424 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
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 400 total points
ID: 1342596
Hi TSCCode,

Glad to help.

Cheers,
Phil.

0
 

Author Comment

by:TCSCode
ID: 1342597
Thanks again.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

829 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