Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
Delphi 10 Seattle Enterprise
|
AW: Probleme mit SHGetKnownFolderPath
25. Nov 2013, 11:45
Also hiermit habe ich keine Probleme
Delphi-Quellcode:
library PathLib;
uses
Winapi.ActiveX,
Winapi.ShellAPI,
Winapi.ShlObj,
Winapi.Windows,
System.SysUtils,
System.Classes;
{$R *.res}
function GetKnownFolderPath( ACSIDL : TGUID ) : WideString;
var
LPath : PWideChar;
begin
if SHGetKnownFolderPath( ACSIDL, 0, 0, LPath ) = S_OK
then
Result := LPath
else
Result := ' ';
end;
function GetSpecialFolder( AFolderID : Integer ) : WideString;
var
LPath : PWideChar;
begin
GetMem( LPath, MAX_PATH * SizeOf( WideChar ) );
try
if SHGetSpecialFolderPathW( 0, LPath, AFolderID, False )
then
Result := LPath
else
Result := ' ';
finally
FreeMem( LPath );
end;
end;
function DocumentRoot : WideString; stdcall;
begin
if CheckWin32Version( 9 )
then
Result := GetKnownFolderPath( StringToGUID( ' {FDD39AD0-238F-46AF-ADB4-6C85480369C7}' ) )
else
Result := GetSpecialFolder( CSIDL_MYDOCUMENTS );
end;
exports
DocumentRoot;
begin
end.
Delphi-Quellcode:
unit View.Main;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
TMainView = class( TForm )
Button1 : TButton;
procedure Button1Click( Sender : TObject );
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
MainView : TMainView;
implementation
{$R *.dfm}
function DocumentRoot : WideString; stdcall; external ' PathLib.dll';
procedure TMainView.Button1Click( Sender : TObject );
begin
Caption := DocumentRoot;
end;
end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
Geändert von Sir Rufo (25. Nov 2013 um 11:51 Uhr)
|
|
Zitat
|