Solved

Program Group

Posted on 1998-08-31
13
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month7 days, 1 hour left to enroll

622 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