Solved

Program Group

Posted on 1998-08-31
13
171 Views
Last Modified: 2010-04-04
Hello
i want to know how to add and delete items from the program
group, startup group actually,
i am using the ancient Delphi 1.Thanx in advance
Mitsy
0
Comment
Question by:Mitsy
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1338196
Hi mitsy,

I don't know anymore if TRegIniFil is available in D1, but here is a way :



                           procedure RunOnStartup(
                             sProgTitle,
                             sCmdLine    : string;
                             bRunOnce    : boolean );
                           var
                             sKey : string;
                             reg  : TRegIniFile;
                           begin
                             if( bRunOnce )then
                               sKey := 'Once'
                             else
                               sKey := '';

                             reg := TRegIniFile.Create( '' );
                             reg.RootKey := HKEY_LOCAL_MACHINE;
                             reg.WriteString(
                               'Software\Microsoft'
                               + '\Windows\CurrentVersion\Run'
                               + sKey + #0,
                               sProgTitle,
                               sCmdLine );
                             reg.Free;
                           end;

Regards, Zif.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1338197
Hey guys, if this doesn't work, here's a component that does this:

http://www.aerosoft.com.au/delphi/progman/index.html

--Matvey
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1338198
(-Not exactly this, another way...)
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Expert Comment

by:BlackDeath
ID: 1338199
and if you really want to enter the startup folder, you can do so by using the WinAPI-function:

 SHGetSpecialFolderLocation

with Parameter

 nFolder=CSIDL_STARTUP

regards,

Black Death.


0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1338200
****. i've lied.

i just tested the following:

(don't forget to add shlobj to the uses-clause!)

procedure TForm1.Button1Click(Sender: TObject);
var
  idList: PITEMIDLIST;
  pPath: PChar;
begin
  pPath := StrAlloc(MAX_PATH);
  SHGetSpecialFolderLocation(handle, CSIDL_STARTUP, idList);
  SHGetPathFromIDList(idList, pPath);
  Edit1.Text := StrPas(pPath);
  StrDispose(pPath);
end;

which could easily be whipped together from win32.hlp, but:

this one returns the autostart-folder, not "startup".

can you live with that?

(i mean, it's not too hard a job to replace "autostart" with "startup" in the resulting string and to create this folder, if not existing, what do you think?)

hope this helps you.

regards,
Black Death.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1338201
BlackDeath,

(1)
GetSpecialFolder(CSIDL_STARTUP) returns "Startup" in the english version and "AutoStart" in your german version. That's the sense of GetSpecialFolderLocation...

(2)
you've forgotten to free the idList!!!!!

procedure FreePidl(var pidl: PItemIDList);
var malloc : IMalloc;
begin
  if (pidl<>nil) and (SHGetMalloc(malloc)=NOERROR) then begin
    malloc.Free(pidl);
    pidl:=nil;
  end;
end;

Regards, Madshi.
0
 

Author Comment

by:Mitsy
ID: 1338202
Hey Guys this is isn't Delphi 1 code. I found how to add an item
but i still dont know how to delete an item from startup menu
Any ideas?
Mitsy
0
 

Author Comment

by:Mitsy
ID: 1338203
wooops the above component does all i need, how do i close the question?
0
 
LVL 3

Accepted Solution

by:
Matvey earned 30 total points
ID: 1338204
Hey there. Glad the component works. Just curious, are you making some kind of setup program?

--Matvey
(You can now "close" the question...)
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1338205
Thanx, Madshi -

you're absolutely right!
i want to apologize for being unconcentrated - i've got several things to do at the same time these days...

i think the main advantage with GetSpecial... lies in retrieving e.g. the startup-folder of the current activce profile, if any, or else, default (you know ... the chaos in the profiles subdir when working with several users).

indeed, the language independent access is valuable, too.
imagine: i didn't know that these folders are named differently in englisch and german versions (autostart sound quite non-german to me), but - at the latest when coming to "programs" respectively "programme" i should have noticed.

thanx again.

have a nice day,

Black Death.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1338206
BlackDeath, have a nice day, too.  :-)

P.S: Schöne Grüße aus dem Harz...
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1338207
Re: Grüße

aus Brunswick...

Black Death.
0
 

Author Comment

by:Mitsy
ID: 1338208
very easy to use and useful component
thanx for your help
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

785 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