Solved

Program Group

Posted on 1998-08-31
13
168 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
Comment Utility
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
Comment Utility
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
Comment Utility
(-Not exactly this, another way...)
0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
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
Comment Utility
****. 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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:Mitsy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
BlackDeath, have a nice day, too.  :-)

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

Expert Comment

by:BlackDeath
Comment Utility
Re: Grüße

aus Brunswick...

Black Death.
0
 

Author Comment

by:Mitsy
Comment Utility
very easy to use and useful component
thanx for your help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

13 Experts available now in Live!

Get 1:1 Help Now