Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Konfigurationsdatei ini (https://www.delphipraxis.net/153486-konfigurationsdatei-ini.html)

t0mmy 4. Aug 2010 21:47

Konfigurationsdatei ini
 
Hallo

Und zwar hab ich folgendes Problem: Ich hab ein Programm geschrieben, das Menüpunkt mit Pfadeinstellung besitzt.
Dort kann ich die Quell- und Zielpfade eingeben und per Button wird dies in ein .ini file Geschrieben jetzt möcht ich das ini-File nach den Pfadeinstellungen per OK-Button auf C:\ abspeichern jedoch bekomm ich bei Ausführung einen Zugriffsfehler was mir klar ist.



Delphi-Quellcode:
  ini:=TIniFile.Create('C:\rxmlkonfig.ini'); // Hier der Zugriffsfehler
try
    ini.WriteString('Pfadeinstellungen','Quelle',Quelle+'\');
    ini.WriteString('Pfadeinstellungen','Ziel',Ziel+'\');
finally
  ini.free
end;

Gibt es eine möglichkeit über Delphi Zugriffsrechte für das Erstellen einer .ini Datei auf C:\ per Befehl etc zu erlangen?

Matze 4. Aug 2010 21:52

AW: Konfigurationsdatei ini
 
Hallo,

dann hast du - wie die wenigsten - keine Schreibrechte auf C:\ und das ist auch gut so.
Die Dateien gehören nicht nach C:\ sondern ins Anwendungsdaten-Verzeichnis. Wo sich das unter Vista/Win7 genau befindet, weiß ich nicht, aber unter WinXP war's "Dokumente und Einstellungen\<user>\Anwendungsdaten\Anwendungsnam e\".

In der DP gibt's genug Funktionen, um den Pfad zu ermitteln, evtl. hilft schon SpecialFoldersSpecialFolders.

Grüße, Matze

blackfin 4. Aug 2010 22:02

AW: Konfigurationsdatei ini
 
Das Programmdaten (Root-)Verzeichnis für alle Benutzer ist CSIDL_COMMON_APPDATA ($0023), für den Benutzer allein zugehörig CSIDL_APPDATA ($001A).

Unit, um die Pfade der verfügbaren Windows-Special-Folder zu ermitteln, inklusive deren Konstanten und Beschreibung:

Delphi-Quellcode:
unit specialfolders;

{
  Function for retrieving the paths of the Microsoft Windows special folders.
  Constants of the available special folders below.
  Systems: Win 2000, Win XP, Vista, Windows 7
}

interface

uses
  Windows, SysUtils, ShlObj

;

function getWinSpecialFolder(CSIDLFolder : integer) : string;

const

  CSIDL_COMMON_APPDATA = $0023;
  CSIDL_FLAG_CREATE = $8000;
  CSIDL_ADMINTOOLS = $0030;
  CSIDL_ALTSTARTUP = $001D;
  CSIDL_APPDATA = $001A;
  CSIDL_BITBUCKET = $000A;
  CSIDL_CDBURN_AREA = $003B;
  CSIDL_COMMON_ADMINTOOLS = $002F;
  CSIDL_COMMON_ALTSTARTUP = $001E;
  CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
  CSIDL_COMMON_DOCUMENTS = $002E
  CSIDL_COMMON_FAVORITES = $001F;
  CSIDL_COMMON_MUSIC = $0035;
  CSIDL_COMMON_PICTURES = $0036;
  CSIDL_COMMON_PROGRAMS = $0017;
  CSIDL_COMMON_STARTMENU = $0016;
  CSIDL_COMMON_STARTUP = $0018;
  CSIDL_COMMON_TEMPLATES = $002D;
  CSIDL_COMMON_VIDEO = $0037;
  CSIDL_CONTROLS = $0003;
  CSIDL_COOKIES = $0021;
  CSIDL_DESKTOP = $0000;
  CSIDL_DESKTOPDIRECTORY = $0010
  CSIDL_DRIVES = $0011;
  CSIDL_FAVORITES = $0006;
  CSIDL_FONTS = $0014;
  CSIDL_HISTORY = $0022;
  CSIDL_INTERNET = $0001;
  CSIDL_INTERNET_CACHE = $0020;
  CSIDL_LOCAL_APPDATA = $001C
  CSIDL_MYDOCUMENTS = $000C
  CSIDL_MYMUSIC = $000D;
  CSIDL_MYPICTURES = $0027;
  CSIDL_MYVIDEO = $000E;
  CSIDL_NETHOOD = $0013;
  CSIDL_NETWORK = $0012;
  CSIDL_PERSONAL = $0005;
  CSIDL_PRINTERS = $0004;
  CSIDL_PRINTHOOD = $001B;
  CSIDL_PROFILE = $0028;
  CSIDL_PROFILES = $003E;
  CSIDL_PROGRAM_FILES = $0026;
  CSIDL_PROGRAM_FILES_COMMON = $002B;
  CSIDL_PROGRAMS = $0002;
  CSIDL_RECENT = $0008;
  CSIDL_SENDTO = $0009;
  CSIDL_STARTMENU = $000B;
  CSIDL_STARTUP = $0007
  CSIDL_SYSTEM = $0025;
  CSIDL_TEMPLATES = $0015;
  CSIDL_WINDOWS = $0024;

{
      CSIDL_FLAG_CREATE            (0x8000) Version 5.0.
          Combine this CSIDL with any of the following CSIDLs to force the creation of the associated
          folder.

      CSIDL_ADMINTOOLS             (0x0030) Version 5.0.
          The file system directory that is used to store administrative tools for an individual user.
          The Microsoft Management Console (MMC) will save customized consoles to this
          directory, and it will roam with the user.

      CSIDL_ALTSTARTUP             (0x001d)               The file system
        directory that corresponds to the user's nonlocalized Startup program group.

      CSIDL_APPDATA                (0x001a) Version 4.71. The 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_BITBUCKET              (0x000a)               The virtual folder
        containing the objects in the user's Recycle Bin.

      CSIDL_CDBURN_AREA            (0x003b) Version 6.0. The file system
        directory acting as a staging area for files waiting to be written to CD. A
        typical path is C:\Documents and Settings\username\Local
        Settings\Application Data\Microsoft\CD Burning.

      CSIDL_COMMON_ADMINTOOLS      (0x002f) Version 5.0. The file system
        directory containing administrative tools for all users of the computer.

      CSIDL_COMMON_ALTSTARTUP      (0x001e)               The file system
        directory that corresponds to the nonlocalized Startup program group for all
        users. Valid only for Microsoft Windows NT systems.

      CSIDL_COMMON_APPDATA         (0x0023) Version 5.0. The file system
        directory containing application data for all users. A typical path is
        C:\Documents and Settings\All Users\Application Data.

      CSIDL_COMMON_DESKTOPDIRECTORY (0x0019)               The 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_COMMON_DOCUMENTS       (0x002e)               The file system
        directory that contains documents that are common to all users. A typical
        paths is C:\Documents and Settings\All Users\Documents. Valid for Windows NT
        systems and Microsoft Windows 95 and Windows 98 systems with Shfolder.dll
        installed.

      CSIDL_COMMON_FAVORITES       (0x001f)               The file system
        directory that serves as a common repository for favorite items common to
        all users. Valid only for Windows NT systems.

      CSIDL_COMMON_MUSIC           (0x0035) Version 6.0. The file system
        directory that serves as a repository for music files common to all users. A
        typical path is C:\Documents and Settings\All Users\Documents\My Music.

      CSIDL_COMMON_PICTURES        (0x0036) Version 6.0. The file system
        directory that serves as a repository for image files common to all users. A
        typical path is C:\Documents and Settings\All Users\Documents\My Pictures.

      CSIDL_COMMON_PROGRAMS        (0x0017)               The file system
        directory that contains the directories for the common program groups that
        appear on 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_STARTMENU       (0x0016)               The 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_STARTUP         (0x0018)               The 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_TEMPLATES       (0x002d)               The 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_VIDEO           (0x0037) Version 6.0. The file system
        directory that serves as a repository for video files common to all users. A
        typical path is C:\Documents and Settings\All Users\Documents\My Videos.

      CSIDL_CONTROLS               (0x0003)               The virtual folder
        containing icons for the Control Panel applications.

      CSIDL_COOKIES                (0x0021)               The file system
        directory that serves as a common repository for Internet cookies. A typical
        path is C:\Documents and Settings\username\Cookies.

      CSIDL_DESKTOP                (0x0000)               The virtual folder
        representing the Windows desktop, the root of the namespace.

      CSIDL_DESKTOPDIRECTORY       (0x0010)               The 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                 (0x0011)               The virtual folder
        representing My Computer, containing everything on the local computer:
        storage devices, printers, and Control Panel. The folder may also contain
        mapped network drives.

      CSIDL_FAVORITES              (0x0006)               The 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_FONTS                  (0x0014)               A virtual folder
        containing fonts. A typical path is C:\Windows\Fonts.

      CSIDL_HISTORY                (0x0022)               The file system
        directory that serves as a common repository for Internet history items.

      CSIDL_INTERNET               (0x0001)               A virtual folder
        representing the Internet.

      CSIDL_INTERNET_CACHE         (0x0020) Version 4.72. The file system
        directory that serves as a common repository for temporary Internet files. A
        typical path is C:\Documents and Settings\username\Local Settings\Temporary
        Internet Files.

      CSIDL_LOCAL_APPDATA          (0x001c) Version 5.0. The 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_MYDOCUMENTS            (0x000c) Version 6.0. The virtual folder
        representing the My Documents desktop item.

      CSIDL_MYMUSIC                (0x000d)               The file system
        directory that serves as a common repository for music files. A typical path
        is C:\Documents and Settings\User\My Documents\My Music.

      CSIDL_MYPICTURES             (0x0027) Version 5.0. The file system
        directory that serves as a common repository for image files. A typical path
        is C:\Documents and Settings\username\My Documents\My Pictures.

      CSIDL_MYVIDEO                (0x000e) Version 6.0. The file system
        directory that serves as a common repository for video files. A typical path
        is C:\Documents and Settings\username\My Documents\My Videos.

      CSIDL_NETHOOD                (0x0013)               A file system
        directory containing the link objects that may exist in the My Network
        Places virtual folder. It is not the same as CSIDL_NETWORK, which represents
        the network namespace root. A typical path is C:\Documents and
        Settings\username\NetHood.

      CSIDL_NETWORK                (0x0012)               A virtual folder
        representing Network Neighborhood, the root of the network namespace
        hierarchy.

      CSIDL_PERSONAL               (0x0005) Version 6.0. The virtual folder
        representing the My Documents desktop item. This is equivalent to

    CSIDL_MYDOCUMENTS. Previous to Version 6.0. The file system directory used
        to physically store a user's common repository of documents. A typical path
        is C:\Documents and Settings\username\My Documents. This should be
        distinguished from the virtual My Documents folder in the namespace. To
        access that virtual folder, use SHGetFolderLocation, which returns the
        ITEMIDLIST for the virtual location, or refer to the technique described in
        Managing the File System.

      CSIDL_PRINTERS               (0x0004)               The virtual folder
        containing installed printers.

      CSIDL_PRINTHOOD              (0x001b)               The 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_PROFILE                (0x0028) Version 5.0. The user's profile
        folder. A typical path is C:\Documents and Settings\username. Applications
        should not create files or folders at this level; they should put their data
        under the locations referred to by CSIDL_APPDATA or CSIDL_LOCAL_APPDATA.

      CSIDL_PROFILES               (0x003e) Version 6.0. The file system
        directory containing user profile folders. A typical path is C:\Documents
        and Settings.

      CSIDL_PROGRAM_FILES          (0x0026) Version 5.0. The Program Files
        folder. A typical path is C:\Program Files.

      CSIDL_PROGRAM_FILES_COMMON   (0x002b) 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, Windows 2000, and Windows XP
        systems. Not valid for Windows Millennium Edition (Windows Me).

      CSIDL_PROGRAMS               (0x0002)               The file system
        directory that contains the user's program groups (which are themselves file
        system directories). A typical path is C:\Documents and
        Settings\username\Start Menu\Programs.

      CSIDL_RECENT                 (0x0008)               The file system
        directory that contains shortcuts to the user's most recently used
        documents. A typical path is C:\Documents and Settings\username\My Recent
        Documents. 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 My Recent Documents submenu of
        the Start menu.

      CSIDL_SENDTO                 (0x0009)               The file system
        directory that contains Send To menu items. A typical path is C:\Documents
        and Settings\username\SendTo.

      CSIDL_STARTMENU              (0x000b)               The file system
        directory containing Start menu items. A typical path is C:\Documents and
        Settings\username\Start Menu.

      CSIDL_STARTUP                (0x0007)               The file system
        directory that corresponds to the user's Startup program group. The system
        starts these programs whenever any user logs onto Windows NT or starts
        Windows 95. A typical path is C:\Documents and Settings\username\Start
        Menu\Programs\Startup.

      CSIDL_SYSTEM                 (0x0025) Version 5.0. The Windows System
        folder. A typical path is C:\Windows\System32.

      CSIDL_TEMPLATES              (0x0015)               The file system
        directory that serves as a common repository for document templates. A
        typical path is C:\Documents and Settings\username\Templates.

      CSIDL_WINDOWS                (0x0024) Version 5.0. The Windows
        directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT%
        environment variables. A typical path is C:\Windows.
}

implementation

function getWinSpecialFolder(CSIDLFolder : integer) : string;
begin
  SetLength(Result, MAX_PATH);
  SHGetSpecialFolderPath(0, PChar(Result), CSIDLFolder, false);
  SetLength(Result, StrLen(PChar(Result)));
  if (Result <> '') then Result := IncludeTrailingBackslash(Result);
end;

end.

xZise 4. Aug 2010 22:11

AW: Konfigurationsdatei ini
 
Zitat:

Zitat von Matze (Beitrag 1039649)
Hallo,

dann hast du - wie die wenigsten - keine Schreibrechte auf C:\ und das ist auch gut so.[...]

Da muss ich dir leider widersprechen: Ich habe z.B. Schreibrechte auf C:\ Windows 7 mit UAC (auf höchster Stufe).

MfG
Fabian

Matze 4. Aug 2010 22:14

AW: Konfigurationsdatei ini
 
Zitat:

Zitat von xZise (Beitrag 1039653)
Zitat:

Zitat von Matze (Beitrag 1039649)
dann hast du - wie die wenigsten - keine Schreibrechte auf C:\ und das ist auch gut so.[...]

Da muss ich dir leider widersprechen: Ich habe z.B. Schreibrechte auf C:\ Windows 7 mit UAC (auf höchster Stufe).

Öhm ok. Und das, ohne auf "Zulassen" klicken zu müssen? :gruebel: Denn das fordert die Rechte dann natürlich an.

Ich ging davon aus, dass Microsoft das konsequent umgesetzt hat. Wieder was gelernt.
D.h. natürlich nicht, dass man die Daten auf C:\ speichern soll. ;)

blackfin 4. Aug 2010 22:21

AW: Konfigurationsdatei ini
 
Zitat:

Ich habe z.B. Schreibrechte auf C:\ Windows 7 mit UAC
Und du bist nicht zufällig als Admin eingeloggt, dein Delphi-Programm startet aber nicht mit Admin-Rechten? :wink:
Du kannst nämlich als eingeloggter Admin auch mit aktivierter UAC auf dem C:-Root rumwerkeln wie du lustig bist und eine Datei erstellen, und das ganze ohne bösen Dialog, aber wenn dein Delphi-Programm nicht als Admin startet (was der standard ist), hat es keine Schreibrechte aufs C:-Root.

@t0mmy:
Probier mal, ob das Programm über Rechtsklick => Als Administrator ausführen... immer noch den Fehler erzeugt :)

Während der Laufzeit hast du keine Möglichkeit, die Rechte deines Programms per Code zu erweitern, das wäre auch gegen den Sinn des Rechte-Systems.
Du hast nun aber zwei drei Möglichkeiten, um dein Problem zu lösen:


1) Die grauslige Variante
#########################
Du forderst über ein Manifest generell Admin-Rechte beim Programm-Start für dein Programm an. Wie das geht, verrät dir die Suchfunktion.
Dann kannst du auch deine INI-Datei auf dem C-Root ablegen. Das halte ich aber für wirklich schlimm und ist nicht zu empfehlen.
Stell dir vor, alle Programme würden ihre Konfig-Einstellungen auf dem C:-Root ablegen? Wir leben doch nicht in der Steinzeit! :)

2) Die richtige Variante
########################
Du legst deine INI-Datei da ab, wo sie hingehört: Entweder in (einen Unterordner von) CSIDL_COMMON_APPDATA, oder Benutzer-bezogen in CSIDL_APPDATA.
Hierbei sei aber noch erwähnt, dass ein Programm ohne Admin-Rechte erstmal auch da keinen Schreibzugriff hat. Den Schreibzugriff auf einen Unterordner dieser beiden genannten Spezial-Verzeichnisse muss das Installationsprogramm des Programms freigeben, das ja normalerweise mit Admin-Rechten läuft und es somit auch kann. Das erfordert zwar etwas Mehraufwand, aber so ist es von Microsoft vorgesehen.

3) Die "Das ist mir alles zu kompliziert"-Methode (sozusagen Variante 1.1)
################################################## ##########################
Du baust kein Manifest ein und nimmst auch keinen Specialfolder, sondern verteufelst Microsoft wegen dem dämlichen Rechtesystem und sagst deinen Benutzern, sie sollen das Programm jedesmal über "Rechtsklick => Als Administrator ausführen..." starten, damit es keine AV gibt.
Nunja, was soll ich sagen....wer sowas macht, sollte vielleicht lieber Äpfel auf dem Stadtmarkt verkaufen :D

Ich lege dir die Variante zwei ans Herz, jeder User wirds dir danken! :-D

mkinzler 5. Aug 2010 05:26

AW: Konfigurationsdatei ini
 
Oder Version Evil deluxe: Anwender auffordern Berechtigungen für die gesammte Platte zuzulassen

t0mmy 6. Aug 2010 16:06

AW: Konfigurationsdatei ini
 
Hallo, sry das so lange gedauert hat, aber ich hab kurzzeitig kein inet gehabt.

Jetzt gehts aber wieder :)

Ja das mit ausführen als Admin geht, nur möchte ich das nicht!

Ich will einfach ein SChreibrecht auf C: haben das wär alles :(

achja das mit den SpecialFolders wird mir weniger helfen, denn der Ordner in dem ich die Datei schreiben will is auf C:\

blackfin 6. Aug 2010 16:09

AW: Konfigurationsdatei ini
 
Zitat:

Ja das mit ausführen als Admin geht, nur möchte ich das nicht!
Zitat:

Ich will einfach ein SChreibrecht auf C: haben das wär alles
Das schliesst sich gegenseitig aus!

Ausser, du nimmst mkinzler's Variante "evil Deluxe" (bitte nicht!)

t0mmy 6. Aug 2010 16:26

AW: Konfigurationsdatei ini
 
:(

Gibt es denn eine möglichkeit Programmtechnisch das PRogramm als Admin laufen zu lassen?
Also nicht links-Klick --> Ausführen als Admin

blackfin 6. Aug 2010 16:28

AW: Konfigurationsdatei ini
 
Gibt es, Variante 1)....


Btw:
Zitat:

achja das mit den SpecialFolders wird mir weniger helfen, denn der Ordner in dem ich die Datei schreiben will is auf C:\
Die Specials-Folder liegen normalerweise auch auf C:, aber du willst ja ins C:-Root schreiben!

p80286 6. Aug 2010 16:45

AW: Konfigurationsdatei ini
 
Das sich da jemand gegen die Special-Folders wehrt, kann ich gut nachvollziehen. So chaotisch sie angelegt sind.

Aber das Prinzip ist schon in Ordnung. Ein Verzeichnis für Programme und zugehörige Daten, ggf. nach unterschiedlichen Benutzern aufgeteilt, da kann man gut die Rechte vergeben, und wenn man's dokumentiert hat, dann ist das auch wartungsfeundlich.

Entschuldigung, wer heute noch direkt unter C:\ seine Daten ablegen will, der ist gedanklich über CP/M und Disketten noch nicht hinausgekommen.

@blackfin C:\ muß nicht zwangsläufig für "normale" Benutzer gesperrt sein, Ist es in der Praxis aber gottseidank.

Gruß
K-H

Luckie 6. Aug 2010 17:12

AW: Konfigurationsdatei ini
 
Doch. Eben mit Manifest, in dem du zwangsweise Adiminstratorenrechte anforderst. Nur müssen dann jedem, der dein Programm nutzt, auch die Administratorenzugangsdaten kennen. Privat mag das ja noch gehen, aber bei Rechnern mit mehreren Bneutzern könnte e da schon Probleme geben.

Warum muss es denn unbedingt im Wurzelverzeichnis von C:\ sein?

mkinzler 6. Aug 2010 18:34

AW: Konfigurationsdatei ini
 
Am Besten wäre es, wenn du den Pfad verwenden würdest, den Microsoft dafür vorsieht. (Siehe #2/#3)

t0mmy 6. Aug 2010 20:03

AW: Konfigurationsdatei ini
 
Sry das ich das Thema nochmal pushe aber ich bevor ich sinnlose Fragen poste überleg ich liebe ne zeit lang wie mans am besten lösen könnte doch ich verzweifel

Könnt ihr mir sagen wie mein Problem am besten lösen könnte?

Und zwar ich hab ein Programm das nur aus einer *.exe besteht und nach ausführen ein Formularfenster zum einstellen Pfade erscheint. Dort trag ich mein Quell- also wo ich die xml-Datei herausholen kann und den Zielpfad
wo ich meine bearbeitetes file hinspeichern soll.
Auf OK geklickt erstellt er ein ini file mit dem Quell- und Zielpfad.
Im hauptfenster kann ich dann per combobox die zu bearbeitete xml datei Aussuchen. Dann trag ich noch ein paar werte ein in zwei edit felder und auf ok bearbeitet er das File und speichert es im Zielpfad welches auf C liegt.
Dort hab ich aber kein Zugriffsrecht außer als Ausführung als Admin.

Ich würd gern dazu Fragen stellen aber ich weiss nicht welche frage ich stellen soll außer wie ich das am Besten lösen kann mit der Konfigurationsdatei und dem Zielordner.

Ein lösungsvorschlag von einem Freund wär es einen Ordner zu erstellen unter XP auf C:\Programme\MeinProgramm\*.exe und den Pfad direkt im Programm zu schreiben jedoch was ist, wenn ich aber Programme auf D oder E:\ hab dann erscheint doch eine fehlermeldung?! :S

mkinzler 6. Aug 2010 20:06

AW: Konfigurationsdatei ini
 
Warum verfolgst du nicht wuie schon öfzers gesagt den sicheren offiziellen Weg?

Luckie 6. Aug 2010 21:10

AW: Konfigurationsdatei ini
 
Ich habe das Gefühl unsere Antworten werden nicht gelesen oder werden einfach ignoriert. :?

xZise 6. Aug 2010 22:39

AW: Konfigurationsdatei ini
 
Moin Matze,
Zitat:

Zitat von Matze (Beitrag 1039654)
Zitat:

Zitat von xZise (Beitrag 1039653)
Zitat:

Zitat von Matze (Beitrag 1039649)
dann hast du - wie die wenigsten - keine Schreibrechte auf C:\ und das ist auch gut so.[...]

Da muss ich dir leider widersprechen: Ich habe z.B. Schreibrechte auf C:\ Windows 7 mit UAC (auf höchster Stufe).

Öhm ok. Und das, ohne auf "Zulassen" klicken zu müssen? :gruebel: Denn das fordert die Rechte dann natürlich an.[...]

Also ehrlich dumm bin ich nicht. Ähm nein, ich klicke auf "Neuer Ordner" und plubs ist da ein neuer Ordner.

Zitat:

Zitat von Matze (Beitrag 1039654)
Ich ging davon aus, dass Microsoft das konsequent umgesetzt hat. Wieder was gelernt.
D.h. natürlich nicht, dass man die Daten auf C:\ speichern soll. ;)

Klar aber ich kenne ein Programm was davon „Gebrauch“ macht (und sich strickt dagegen wehrt die Anwendungsdaten o.ä. zu verwenden).

MfG
Fabian

PS: Und achte bitte auf das in der Klammer: Wenn ich in C:\Programme einen erstellen erscheint ein Dialog.
PPS: Und ja ich bin Administrator mit UAC. Aber Administrator mit UAC heißt doch nur, dass man kein Passwort brauch um Adminrechte zu bekommen.

hoika 7. Aug 2010 06:26

AW: Konfigurationsdatei ini
 
Hallo,

aus #2

Delphi-Quellcode:
function getWinSpecialFolder(CSIDLFolder : integer) : string;
Was als CSIDLFolder genommen werden soll, wurde bereits gesagt.

Ergebnis ist ein Pfad, in das das Programm auf jeden Fall schreiben kann.
Also noch den Ininamen hintendran und alles sollte funktionieren.

Wo ist das Problem ?


Heiko

mkinzler 7. Aug 2010 07:09

AW: Konfigurationsdatei ini
 
Zitat:

Wo ist das Problem ?
Das er wohl partout ins Root von C: schreiben will :zwinker:

xZise 7. Aug 2010 08:58

AW: Konfigurationsdatei ini
 
Moin,
das gehört eigentlich geschlagen :P Ich zumindest würde die Anwendung vermutlich nicht einsetzen (bis auf SWAT 4, das „darf“ das).

Es ist halt so, dass nicht jeder überall Schreibrechte hat. Ob man auf C:\ Rechte hat, kann ich nicht sagen, bei mir schon, aber bei anderen nicht. Aber was ist auch, wenn C:\ nur das Datengrab für Windows (also den Kernel etc.) ist, und auf D:\ die Programme und E:\ die Eigenen Dateien liegen ;) Deshalb nehme bitte bitte keine hart kodierten Pfade sondern biete folgendes an:

Lass den Benutzer bei der Installation (wenn es eine gibt) oder den ersten Start wählen, wo deine Programmdaten gespeichert werden: Entweder im Programmordner oder in den Anwendungsdaten. An den Programmordner kommst du mit
Delphi-Quellcode:
ExtractFilePath(ParamStr(0))
und an die Anwendungsdaten bekommst du wie weiter unten beschrieben.

Und warum das ganze?
  1. Die Anwendungsdaten existieren immer!
  2. Man hat immer darin Schreib/Leserechte!
  3. Jeder Benutzer kann eine eigene Konfiguration anlegen!
  4. Und falls das Ding portabel sein soll, dann kann man immer noch sagen dass es im Programmordner gespeichert werden soll.

Da wären wir übrigens bei den nächsten Problem, wenn es portabel sein soll/kann dann bringt dir das Speichern in C:\ nichts aus zwei Gründen:
  1. Alles wird zurückgesetzt, wenn der PC geändert wird.
  2. Wenn du das Programm mal schnell beim Freund testest müllst du den PC zu.

So und jetzt bist du dran: Nenne mit einen Vorteil, warum man auf C:\ speichern soll?

MfG
Fabian

PS: C:\ = der Ordner direkt in C:\ nicht ein Unterordner in C:\!

t0mmy 7. Aug 2010 09:26

AW: Konfigurationsdatei ini
 
Ich bin voll und ganz deiner Meinung ich hab das Problem mit der Konfigurations.ini mit Special Folders gelöst jedoch hab ich immer noch das Problem mit dem Schreibrecht auf C wenn ich meine bearbeitete xml dort hinspeichern möchte


Achja welchen Special Folder würdet ihr nehmen um eine .ini (Konfigurationsdatei) abzuspeichern
(Dieser Ordner sollte auf allen XP versionen vorhanden sein)

himitsu 7. Aug 2010 09:31

AW: Konfigurationsdatei ini
 
Wie wäre es denn mit offiziellen Ordnern in der Registry?
M$ sagt ja, daß INI out sind.

xZise 7. Aug 2010 09:48

AW: Konfigurationsdatei ini
 
Moin
Zitat:

Zitat von t0mmy (Beitrag 1040123)
Ich bin voll und ganz deiner Meinung ich hab das Problem mit der Konfigurations.ini mit Special Folders gelöst jedoch hab ich immer noch das Problem mit dem Schreibrecht auf C wenn ich meine bearbeitete xml dort hinspeichern möchte

Und wieso willst du schon wieder was dahin speichern. Oder meinst du in einen Unterordner?


Zitat:

Zitat von t0mmy (Beitrag 1040123)
Achja welchen Special Folder würdet ihr nehmen um eine .ini (Konfigurationsdatei) abzuspeichern
(Dieser Ordner sollte auf allen XP versionen vorhanden sein)

AppData ;) Der wird unter XP und Nachfolgende und imho auch alle NT Vorgänger angeboten.

MfG
Fabian

t0mmy 7. Aug 2010 10:05

AW: Konfigurationsdatei ini
 
@xZise

Wills jetzt dort in einem Unterordner :) abspeichern, denn ich zuvor erstellt haben.

Kann ich das Manuell mit links-klick und Vollzugriff erlauben?

Matze 7. Aug 2010 10:11

AW: Konfigurationsdatei ini
 
Wie zig-fach erwähnt ist es unsinnig, da zu speichern, wo man normalerweise keine Schreibrechte hat.
Das wird dir jeder übel nehmen, der von dir eine Software verwenden möchte.

Ich würde für dein Programm garantiert keine Ausnahme in Sachen Schreibrechten festlegen. ;)

xZise 7. Aug 2010 13:54

AW: Konfigurationsdatei ini
 
Zitat:

Zitat von t0mmy (Beitrag 1040127)
@xZise

Wills jetzt dort in einem Unterordner :) abspeichern, denn ich zuvor erstellt haben.

Aber doch bitte bitte bitte bitte bitte nicht direkt in C:\ (einen Ordner erstellen)! Nehme die Eigenen Dateien, oder den Ordner wo das Programm drin ist, oder die Anwendungsdaten, wenn der Benutzer damit nichts zu tun haben soll!

Zitat:

Zitat von t0mmy (Beitrag 1040127)
Kann ich das Manuell mit links-klick und Vollzugriff erlauben?

Das könntest du, dann funktioniert bei mir wenigstens das Programm nicht :mrgreen:

MfG
Fabian


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz