Avatar billede eldaria Nybegynder
13. januar 2003 - 16:59 Der er 12 kommentarer og
1 løsning

Lade brugeren vælge om programmet skal starte med Windows?

Jeg vil gerne lave en funktion i min Application hvor brugeren skal have mulighed for at vælge at programmet skal starte op automatiskt eller ej.

Hvordan går man nemmest til veje her?
Avatar billede martin_moth Mester
13. januar 2003 - 17:26 #1
Laver en genvej til programmet, som ligger i samme mappe som programmet er installeret.

1) Vælger brugeren automatisk opstart, kopieres genvejen til windows startmappen.
2) Vælger brugeren, at der ikke skal startes automatisk, tjekkes om filen findes i windows startmappen. Gør den det, slettes den
Avatar billede eldaria Nybegynder
13. januar 2003 - 17:30 #2
Den er svær for når brugeren installere vælger han selv hvor programmet bliver installeret dvs, man ved aldrig hvor den genvej skal pege til.
Avatar billede martin_moth Mester
13. januar 2003 - 17:34 #3
Kik på App.path i hjælpen - den returnerer stien til programmet...
Men hvis brugeren installerer via et installationsprogram, kan han/hun så ikke vælge at det skal starte hver gang?
Avatar billede eldaria Nybegynder
13. januar 2003 - 17:38 #4
Jeg kender godt app.path, men det hjæper ikke meget da jeg ikke kender en funktion at inde fra vb oprette en genvej.

Jo det er da muligt at vælge under installationen, men det jeg søger er at brugeren kan vælge efter installationen. dvs. fra applicationen.
Avatar billede martin_moth Mester
13. januar 2003 - 17:43 #5
Ahhh - jeg havde vist ikke gennemtænkt det helt :o(
Hvis man fandt på en måde til at få VB til at oprette en genvej, så var alle problemer løst...
Hmmm - går hjem nu (fyraften), og tænker lidt over det. I mellemtiden kan det være andre klogere hoveder kommer med ideer :o)
Avatar billede martin_moth Mester
13. januar 2003 - 18:09 #6
Ahh - en cykeltur, og så var ideen der.

LAv en lille batfil, som du kan kopierer rundt:

Open App.Path & "\StartProgram.bat" for Output as #1
  print #1 App.Path & "\VBProgram.exe"
Close #1

Herefter kan du kopiere StartProgram.bat til windows-startmappen efter samme princip som jeg har beskrevet - StartProgram.bat fungerer som en genvej (forudsat dit VB-program hedder VBProgram.exe:o)
Avatar billede eldaria Nybegynder
13. januar 2003 - 20:36 #7
Den løsning havde jeg overvejet, den er lidt klumpet men virker.
Eneste problem med den er OS forskelle.
Forskellige Windows versioner putter start mapen forskellige steder.
Og Windows 98, gør det også forskelligt om man har sat brugere op eller om man bruger kun en brugere.
Og forskellige sprog har forskellige navn på mapperne.

For exemepel. Start mappen på en Standard Dansk Windows 98.
C:\Windows\Start Menu\Programmer\Start

Start Mappen på en Engelsk Windows 2000:
C:\Documents and Settings\Brian Levinsen\Start Menu\Programs\Startup

Start Mappen på en engelsk Windows 98 med brugere sat op:
C:\Windows\Users\Brian\Start Menu\Programs\Startup

Ja guderne må vide hvor den er på Franske, Tyske, Græske Windows versioner.

Jeg har dog fortsat undersøge lidt, Det virker til at en der følger dem alle er det der starter fra Regsitret.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Existerer på alle windows jeg har haft mulighed for at prøve.
Men hvordan i h..... for jeg VB til at redigere i registret? Jeg akn kun finde den hvor den redigerer i dens "Safe area"
Avatar billede eldaria Nybegynder
13. januar 2003 - 20:38 #8
Den er lige gået hen og blevet mewre kompliceret end jeg trode så den får lige en nudge opaf i point. 30->60 point til en løsning.
Avatar billede martin_moth Mester
14. januar 2003 - 09:39 #9
At få VB til at gemme variabler i reg-databasen klares med kommandoer som GetSetting og Putsetting, men det er vist ikke det du søger efter - snarere noget som beskrevet i fx. http://www.eksperten.dk/spm/81327. Der er masser af spørgsmål om emnet, somjeg ikke har så meget forstand på :o(

Men en helt anden ide, er at finde system-mappen på en anden måde - det må kunne gøres med et API-kald af en art. Nu er vi der ude hvor jeg snart ikke kan hjælpe mere, men anbefale at kikke på fx. www.allapi.net. Man må på samme måde som man i VB finder App.Path kunne finde windows startmappen med noget API.

Good luck, Martin
Avatar billede martin_moth Mester
14. januar 2003 - 09:45 #11
Fra ovenstående kan du caop/paste - det er vist lige det du søger, se fx. spørgsmålet "start ved opstart"
Avatar billede athlon-pascal Juniormester
14. januar 2003 - 10:28 #12
Du skal prøve at kigge på en dll-fil der hedder SHFolder.dll, prøv at finde den på din computer. Den er vist fra Microsoft. Du kan bruge den til at finde Start-mappen.
Hvis du ikke har den eller hvis det ikke virker så prøv at downloade http://home11.inet.tele.dk/BakSoft/Download/PBPathList.zip, det er ganske vist en Delphi-komponent, men SHFolder.dll plus et par HTML-filer om SHFolder.dll medfølger.

Se også http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetfolderpath.asp

Fra den ene af HTML-filerne
-------- cut --------
CSIDL Values Enumerated Type

--------------------------------------------------------------------------------

Applications frequently use a number of folders which might not have the same name or location on any given system. For example, the system folder might be called C:\Windows on one system and C:\Winnt on another. CSIDL values provide a unique system-independent way to identify these special folders. The values supersede the use of environment variables for this purpose.

You use a CSIDL in conjunction with one of four Shell functions, SHGetFolderLocation , SHGetFolderPath , SHGetSpecialFolderLocation , and SHGetSpecialFolderPath , to retrieve a special folder's path name or pointer to an item identifier list (PIDL) .

Most CSIDLs correspond to either file system folders or virtual folders. Where the CSIDL identifies a file system folder, a commonly used path is given as an example. Other paths can be used. Some CSIDLs can be mapped to an equivalent %VariableName% environment variable. CSIDLs are more reliable, however, and should be used if possible.

Syntax

typedef enum {
    CSIDL_DESKTOP = 0x0000,
    CSIDL_INTERNET = 0x0001,
    CSIDL_PROGRAMS = 0x0002,
    CSIDL_CONTROLS = 0x0003,
    CSIDL_PRINTERS = 0x0004,
    CSIDL_PERSONAL = 0x0005,
    CSIDL_FAVORITES = 0x0006,
    CSIDL_STARTUP = 0x0007,
    CSIDL_RECENT = 0x0008,
    CSIDL_SENDTO = 0x0009,
    CSIDL_BITBUCKET = 0x000A,
    CSIDL_STARTMENU = 0x000B,
    CSIDL_MYDOCUMENTS = 0x000C,
    CSIDL_MYMUSIC = 0x000D,
    CSIDL_MYVIDEO = 0x000E,
    CSIDL_DESKTOPDIRECTORY = 0x0010,
    CSIDL_DRIVES = 0x0011,
    CSIDL_NETWORK = 0x0012,
    CSIDL_NETHOOD = 0x0013,
    CSIDL_FONTS = 0x0014,
    CSIDL_TEMPLATES = 0x0015,
    CSIDL_COMMON_STARTMENU = 0x016,
    CSIDL_COMMON_PROGRAMS = 0x0017,
    CSIDL_COMMON_STARTUP = 0x0018,
    CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019,
    CSIDL_APPDATA = 0x001A,
    CSIDL_PRINTHOOD = 0x001B,
    CSIDL_LOCAL_APPDATA = 0x001C,
    CSIDL_ALTSTARTUP = 0x001D,
    CSIDL_COMMON_ALTSTARTUP = 0x001E,
    CSIDL_COMMON_FAVORITES = 0x001F,
    CSIDL_INTERNET_CACHE = 0x0020,
    CSIDL_COOKIES = 0x0021,
    CSIDL_HISTORY = 0x0022,
    CSIDL_COMMON_APPDATA = 0x0023,
    CSIDL_WINDOWS = 0x0024,
    CSIDL_SYSTEM = 0x0025,
    CSIDL_PROGRAM_FILES = 0x0026,
    CSIDL_MYPICTURES = 0x0027,
    CSIDL_PROFILE = 0x0028,
    CSIDL_SYSTEMX86 = 0x0029,
    CSIDL_PROGRAM_FILESX86 = 0x002A,
    CSIDL_PROGRAM_FILES_COMMON = 0x002B,
    CSIDL_PROGRAM_FILES_COMMONX86 = 0x002C,
    CSIDL_COMMON_TEMPLATES = 0x002D,
    CSIDL_COMMON_DOCUMENTS = 0x002E,
    CSIDL_COMMON_ADMINTOOLS = 0x002F,
    CSIDL_ADMINTOOLS = 0x0030,
    CSIDL_CONNECTIONS = 0x0031,
    CSIDL_COMMON_MUSIC = 0x0035,
    CSIDL_COMMON_PICTURES = 0x0036,
    CSIDL_COMMON_VIDEO = 0x0037,
    CSIDL_RESOURCES = 0x0038,
    CSIDL_RESOURCES_LOCALIZED = 0x0039,
    CSIDL_COMMON_OEM_LINKS = 0x003A,
    CSIDL_CDBURN_AREA = 0x003B,
    CSIDL_COMPUTERSNEARME = 0x003D,
    CSIDL_FLAG_PER_USER_INIT = 0x0800,
    CSIDL_FLAG_NO_ALIAS = 0x1000,
    CSIDL_FLAG_DONT_VERIFY = 0x4000,
    CSIDL_FLAG_CREATE = 0x8000,
    CSIDL_FLAG_MASK = 0xFF00
} CSIDL Values;

Constants

CSIDL_DESKTOP
Windows desktop—virtual folder that is the root of the name space.
CSIDL_INTERNET
Virtual folder that represents the Internet.
CSIDL_PROGRAMS
File system directory that contains the user's program groups (which are also file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs.
CSIDL_CONTROLS
Virtual folder that contains icons for Control Panel applications.
CSIDL_PRINTERS
Virtual folder that contains installed printers.
CSIDL_PERSONAL
File system directory that serves as a common repository for documents. A typical path is C:\Documents and Settings\username\My Documents. This is different from the My Documents virtual folder in the name space. To access that virtual folder, use the technique described in Managing the File System .
CSIDL_FAVORITES
File system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites.
CSIDL_STARTUP
File system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Microsoft® Windows NT® or starts Microsoft Windows® 98. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup.
CSIDL_RECENT
File system directory that contains the user's most recently used documents. A typical path is C:\Documents and Settings\username\Recent. To create a shortcut in this folder, use SHAddToRecentDocs . In addition to creating the shortcut, this function updates the Shell's list of recent documents and adds the shortcut to the Documents submenu of the Start menu.
CSIDL_SENDTO
File system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo.
CSIDL_BITBUCKET
Virtual folder that contains the objects in the user's Recycle Bin.
CSIDL_STARTMENU
File system directory that contains Start Menu items. A typical path is C:\Documents and Settings\username\Start Menu.
CSIDL_MYDOCUMENTS
Virtual folder that contains the objects in the user's My Documents folder.
CSIDL_MYMUSIC
File system directory that serves as a common repository for music files. A typical path is C:\My Music.
CSIDL_MYVIDEO
File system directory that serves as a common repository for video files.
CSIDL_DESKTOPDIRECTORY
File system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself). A typical path is C:\Documents and Settings\username\Desktop
CSIDL_DRIVES
My Computer—virtual folder that contains everything on the local computer: storage devices, printers, and Control Panel. The folder can also contain mapped network drives.
CSIDL_NETWORK
Network Neighborhood—virtual folder that represents the root of the network namespace hierarchy.
CSIDL_NETHOOD
A file system folder that contains the link objects that can exist in the My Network Places virtual folder. It is not the same as CSIDL , which represents the network namespace root. A typical path is C:\Documents and Settings\username\NetHood.
CSIDL_FONTS
Virtual folder that contains fonts. A typical path is C:\WINNT\Fonts.
CSIDL_TEMPLATES
File system directory that serves as a common repository for document templates.
CSIDL_COMMON_STARTMENU
File system directory that contains the programs and folders that appear on the Start Menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT systems.
CSIDL_COMMON_PROGRAMS
File system directory that contains the directories for the common program groups that appear in the Start Menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs. Valid only for Windows NT systems.
CSIDL_COMMON_STARTUP
File system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT systems.
CSIDL_COMMON_DESKTOPDIRECTORY
File system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop. Valid only for Windows NT systems.
CSIDL_APPDATA
Version 4.71 . File system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data. This CSIDL is supported by the redistributable ShFolder.dll for systems that do not have the Microsoft Internet Explorer 4.0 integrated Shell installed.
CSIDL_PRINTHOOD
File system directory that contains the link objects that can exist in the Printers virtual folder. A typical path is C:\Documents and Settings\username\PrintHood.
CSIDL_LOCAL_APPDATA
Version 5.0 . File system directory that serves as a data repository for local (nonroaming) applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data.
CSIDL_ALTSTARTUP
File system directory that corresponds to the user's nonlocalized Startup program group.
CSIDL_COMMON_ALTSTARTUP
File system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Windows NT systems.
CSIDL_COMMON_FAVORITES
File system directory that serves as a common repository for all user's favorite items. Valid only for Windows NT systems.
CSIDL_INTERNET_CACHE
Version 4.72 . File system directory that serves as a common repository for temporary Internet files. A typical path is C:\Documents and Settings\username\Temporary Internet Files.
CSIDL_COOKIES
File system directory that serves as a common repository for Internet cookies. A typical path is C:\Documents and Settings\username\Cookies.
CSIDL_HISTORY
File system directory that serves as a common repository for Internet history items.
CSIDL_COMMON_APPDATA
Version 5.0 . Application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data.
CSIDL_WINDOWS
Version 5.0 . Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. A typical path is C:\WINNT.
CSIDL_SYSTEM
Version 5.0 . System folder. A typical path is C:\WINNT\SYSTEM32.
CSIDL_PROGRAM_FILES
Version 5.0 . Program Files folder. A typical path is C:\Program Files.
CSIDL_MYPICTURES
Version 5.0 . My Pictures folder. A typical path is C:\Documents and Settings\username\My Documents\My Pictures.
CSIDL_PROFILE
Version 5.0 . User's profile folder.
CSIDL_SYSTEMX86
The x86 system directory on Reduced Instruction Set Computer (RISC) systems.
CSIDL_PROGRAM_FILESX86
The x86 Program Files folder on RISC systems.
CSIDL_PROGRAM_FILES_COMMON
Version 5.0 . A folder for components that are shared across applications. A typical path is C:\Program Files\Common. Valid only for Windows NT and Windows 2000 systems.
CSIDL_PROGRAM_FILES_COMMONX86
The x86 Program Files Common folder on RISC systems.
CSIDL_COMMON_TEMPLATES
File system directory that contains the templates that are available to all users. A typical path is C:\Documents and Settings\All Users\Templates. Valid only for Windows NT systems.
CSIDL_COMMON_DOCUMENTS
File system directory that contains documents that are common to all users. Typical paths are C:\Documents and Settings\All Users\Documents. Valid for Windows NT systems and Windows 95 and Windows 98 systems with Shfolder.dll installed.
CSIDL_COMMON_ADMINTOOLS
Version 5.0 . File system directory that contains administrative tools for all users.
CSIDL_ADMINTOOLS
Version 5.0 . File system directory used to store administrative tools for an individual user. The Microsoft Management Console (MMC) saves customized consoles to this directory, and it roams with the user.
CSIDL_CONNECTIONS
Virtual folder that contains network and dial-up connections.
CSIDL_COMMON_MUSIC
My Music folder for all users. For more information, see CSIDL .
CSIDL_COMMON_PICTURES
My Pictures folder for all users. For more information, see CSIDL .
CSIDL_COMMON_VIDEO
My Video folder for all users. For more information, see CSIDL .
CSIDL_RESOURCES
System resource directory. A typical path is C:\WINNT\Resources.
CSIDL_RESOURCES_LOCALIZED
Localized resource directory. For more information, see CSIDL .
CSIDL_COMMON_OEM_LINKS
Folder containing links to OEM specific applications for all users.
CSIDL_CDBURN_AREA
File system folder used to hold data for burning to a CD. Typically [User Profile Folder]\Local Settings\Applications Data\Microsoft\CD Burning.
CSIDL_COMPUTERSNEARME
Computers Near Me folder. Virtual folder that contains links to nearby computers on the network. Nearness it is established by common work group membership.
CSIDL_FLAG_PER_USER_INIT
Combine this flag with the desired CSIDL_ value to indicate per-user initialization.
CSIDL_FLAG_NO_ALIAS
Combine this flag with the desired CSIDL_ value to force a non-alias version of the PIDL.
CSIDL_FLAG_DONT_VERIFY
Combine this flag with the desired CSIDL_ value to return an unverified folder path.
CSIDL_FLAG_CREATE
Combine this flag with the desired CSIDL_ value to force the creation of the associated folder.
CSIDL_FLAG_MASK
Mask for all possible CSIDL flag values.
Enumerated Type Information

Minimum operating systems Windows 95, Windows NT 4.0, Windows XP 

See Also

SHGetFolderLocation , SHGetFolderPath , SHGetSpecialFolderLocation , SHGetSpecialFolderPath
-------- cut --------
Avatar billede eldaria Nybegynder
15. januar 2003 - 08:08 #13
Martin, den med registret virkede helt fint... Takker for det...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester