AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi SHGetKnownFolderPath liefert keinen Pfad
Thema durchsuchen
Ansicht
Themen-Optionen

SHGetKnownFolderPath liefert keinen Pfad

Ein Thema von Sybok Factor · begonnen am 20. Aug 2010 · letzter Beitrag vom 20. Aug 2010
Antwort Antwort
Benutzerbild von Sybok Factor
Sybok Factor

Registriert seit: 15. Jan 2003
Ort: Billerbeck
39 Beiträge
 
Delphi 2010 Professional
 
#1

SHGetKnownFolderPath liefert keinen Pfad

  Alt 20. Aug 2010, 11:50
Hallo an alle!

Ich habe vor kurzem Delphi 2010 auf Windows 7 neu installiert und habe nun das Problem, dass die alte Funktion SHGetSpecialFolderLocation leider eine Debugger-Exception liefert (Code: 3 "Das System kann den angegebenen Pfad nicht finden"). Also habe ich gegoogelt und lesen müssen, dass ich eine "deprecated" Funktion nutze. Soweit so gut. Jetzt wäre also SHGetKnownFolderPath die beste Wahl. Leider liefert sowohl die Version aus ShlObj als auch die aus einer Unit, die ich einem Forum gefunden habe, als Ergebnis "#0".

Die erste Variante liefert wenigstens zur Laufzeit ein Ergebnis, aber das kann es ja nicht sein. Habt ihr bereits eine funktionierende Lösung in der Konstellation gefunden?

Viele Grüße
Sybok
Jetzte michse verstehen dein Problem!
  Mit Zitat antworten Zitat
blackfin
(Gast)

n/a Beiträge
 
#2

AW: SHGetKnownFolderPath liefert keinen Pfad

  Alt 20. Aug 2010, 12:29
SHGetSpecialFolderPath
  Mit Zitat antworten Zitat
Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#3

AW: SHGetKnownFolderPath liefert keinen Pfad

  Alt 20. Aug 2010, 12:36
Naja, was ist, wenn es den Pfad wirklich nicht gibt?
Soweit ich weiß, wird die alte Funktion noch unterstützt, aber die neue wäre natürlich besser:
Zitat:
SHGetKnownFolderPath Function

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

Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID.

Syntax

HRESULT SHGetKnownFolderPath( REFKNOWNFOLDERID rfid,
DWORD dwFlags,
HANDLE hToken,
PWSTR *ppszPath
);
Parameters

rfid
[in] A reference to the KNOWNFOLDERID that identifies the folder.
dwFlags
[in] The KF_FLAG flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KF_FLAG values.
hToken
[in] An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to access the current user's instance of the folder. However, you may need to assign a value to hToken for those folders that can have multiple users but are treated as belonging to a single user. The most commonly used folder of this type is Documents.
The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security privileges for the particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further discussion of access control issues.

Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the Default User folders requires administrator privileges.

ppszPath
[out] When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder. The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree.
Return Value

Returns S_OK if successful, or an error value otherwise, including the following:

E_INVALIDARG Among other things, this value can indicate that the rfid parameter references a KNOWNFOLDERID that is not present on the system. Not all KNOWNFOLDERID values are present on all systems. Use IKnownFolderManager::GetFolderIds to retrieve the set of KNOWNFOLDERID values for the current system.


Remarks

This function replaces SHGetFolderPath. That older function is now simply a wrapper for SHGetKnownFolderPath.

Function Information

Minimum DLL Version shell32.dll version 6.0.6000 or later
Custom Implementation No
Header shlobj.h
Import library None
Minimum operating systems Windows Vista
Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat
Benutzerbild von Sybok Factor
Sybok Factor

Registriert seit: 15. Jan 2003
Ort: Billerbeck
39 Beiträge
 
Delphi 2010 Professional
 
#4

AW: SHGetKnownFolderPath liefert keinen Pfad

  Alt 20. Aug 2010, 13:35
Erstmal danke für die Antworten. Den Pfad gibt es, ich suche unter anderem nach dem Dokumentenordner und dem ApplicationData Pfad. Beide sind vorhanden, in beiden finde ich auch meine Dateien nach dem Start zur Laufzeit. Der Fehler ist ja "nur" eine Debugging Exception. Wenn ich die Daten im Objektinspektor verfolge, ergibt sich folgendes:

SHGetSpecialFolderLoaction = Liefert "chinesische" Schriftzeichen, in meiner Komponente und zur Laufzeit wird aber der richtige Ordner angegeben. (Unicode Probleme?)

SHGetKnownFolderPath = liefert #0, bei FOLDERID_Documents genauso wie bei FOLDERID_AppData .

Das ist die von mir angesprochene Unit: http://www.delphipraxis.net/135471-u...olderpath.html. (Danke an den Autor!!!).

Außerdem gibt es SHGetKnownFolderPath auch noch in ShlObj, der Aufruf liefert leider das selbe Ergebnis.

Es muss doch möglich sein, dass man unter Windows 7 die Standard Systemordner herausfinden kann?

Viele Grüße
Sybok
Jetzte michse verstehen dein Problem!
  Mit Zitat antworten Zitat
Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#5

AW: SHGetKnownFolderPath liefert keinen Pfad

  Alt 20. Aug 2010, 14:31
Den Pfad gibt es,
Das glaubst aber auch nur Du!

Nein im Ernst, wenn Du nach CSIDL_PROGRAM_FILES fragst, bekommst Du ja nur das zurück, was "irgendwo" definiert wurde. So bekomme ich auf meinem Arbeitsplatzrechner auf die Frage nach CSIDL_MYDOCUMENTS nur die Antwort falscher Parameter und bei CSIDL_COMMON_OEM_LINKS Pfad existiert nicht.

Und was die "Chinesischen" Schriftzeichen angeht, da liegst Du wahrscheinlich mit Deiner Vermutung richtig, obwohl unter Umständen ein Symbol-Font daran schuld sein könnte, ist aber wohl eher unwahrscheinlich.

Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat
ringli

Registriert seit: 7. Okt 2004
504 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: SHGetKnownFolderPath liefert keinen Pfad

  Alt 20. Aug 2010, 14:52
Ich habe das grade mal bei mir unter Windows 7 ausprobiert. Hier bekomme ich auch entsprechend die Pfade angezeigt. Allerdings verwende ich hier noch Delphi 2007. Könnte also durchaus sein das in meiner Unit noch etwas für Delphi 2010 angepasst werden muss.

Was ein möglicher Fehler bei dir sein könnte, ist das die FOLDERID_AppData laut MSDN nicht deklariert ist. Jedoch erklärt das noch nicht das die FOLDERID_Documents bei dir nicht angezeigt wird. Anbei mal ein Testprojekt als ausführbare Datei welches zumindest bei mir die Pfade für
Delphi-Quellcode:
FOLDERID_Documents
FOLDERID_LocalAppData
FOLDERID_LocalAppDataLow
FOLDERID_RoamingAppData
anzeigt.
Angehängte Dateien
Dateityp: rar Project1.rar (220,2 KB, 50x aufgerufen)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz