Solved

How can i use Winexc or ShellExecute to work with inifiles

Posted on 1998-10-12
5
395 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 100 total points
ID: 1342596
Hi TSCCode,

Glad to help.

Cheers,
Phil.

0
 

Author Comment

by:TCSCode
ID: 1342597
Thanks again.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

810 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