Solved

How can i use Winexc or ShellExecute to work with inifiles

Posted on 1998-10-12
5
389 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
indy Tmemory stream non latin charcter issue 2 98
Delphi selector screen 2 69
oracle global variables 4 63
Delphi inherited method 6 61
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

20 Experts available now in Live!

Get 1:1 Help Now