Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Program Group

Posted on 1998-08-31
13
Medium Priority
?
178 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
Technology Partners: 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!

 
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 120 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

824 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