Solved

Program Group

Posted on 1998-08-31
13
169 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
 
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
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.

 

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

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

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 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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 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

23 Experts available now in Live!

Get 1:1 Help Now