Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Windows 7, wie bekomme ich IShellLibrary Interface (https://www.delphipraxis.net/150013-windows-7-wie-bekomme-ich-ishelllibrary-interface.html)

marcos 5. Apr 2010 11:37


Windows 7, wie bekomme ich IShellLibrary Interface
 
Hallo,

Windows 7 hat ein neues Interface IShellLibrary.
In Delphi 2010 ist die Definition bereits vorhanden.
Meine Frage ist: wie kann ich das Interface bekommen? Ich habe versucht in etwa so:

var myShellLibrary: IShellLibrary;

ShellFolder.QueryInterface(IID_IShellLibrary, Pointer(myhellLibrary));

aber das scheint nicht zu funktionieren.

Gruß
marcos

implementation 5. Apr 2010 12:30

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
Zitat:

Zitat von marcos
Delphi-Quellcode:
Pointer(myhellLibrary)

Ich bin mir sicher, dass dort das Problem liegen wird. Prüf mal, was rauskommt.

Zitat:

Zitat von marcos
aber das scheint nicht zu funktionieren.

Genauer geht's nicht?

Ach und für demnächst: [delphi]-Tags nicht vergessen.

daywalker9 5. Apr 2010 12:33

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
Also eigentlich reicht dir diese Funktion:

SHCreateLibrary

Edit:
Zitat:

SHAddFolderPathToLibrary Adds a folder to a library.
SHCreateLibrary Creates an IShellLibrary object.
SHLoadLibraryFromItem Creates and loads an IShellLibrary object from a specified library definition file.
SHLoadLibraryFromKnownFolder Creates and loads an IShellLibrary object for a specified KNOWNFOLDERID.
SHLoadLibraryFromParsingName Creates and loads an IShellLibrary object for a specified path.
SHRemoveFolderPathFromLibrary Removes a folder from a library.
SHResolveFolderPathInLibrary Attempts to resolve the target location of a library folder that has been moved or renamed.
SHResolveLibrary Attempts to find the location of a library.
SHSaveLibraryInFolderPath Saves an IShellLibrary object to disk.
SHShowManageLibraryUI Shows the library management dialog, which enables users to manage the library folders and default save location.

marcos 5. Apr 2010 15:58

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
SHLoadLibraryFromParsingName wäre wohl die richtige Funktion.
Ich habe versucht die Funktion zu deklarieren (Delphi 2010 scheint die Deklaration noch nicht zu haben).
Leider das Programm kompiliert, aber startet auch nicht - keine Fehlermeldung. Was ist da noch falsch?

marcos

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellApi, ShlObj, ActiveX;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    FShellLibrary: IShellLibrary;
  public
    { Public declarations }
  end;


function SHLoadLibraryFromParsingName( libraryParsingName: PWideChar;
                stgmFlags: dword; const riid: TIID; var ppv: Pointer): HResult; stdcall;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function SHLoadLibraryFromParsingName;   external shell32 name 'SHLoadLibraryFromParsingName';

procedure TForm1.FormCreate(Sender: TObject);
begin
   Edit1.Text := '::{031E4825-7B94-4DC3-B131-E946B44C8DD5}\Documents.library-ms'; // ParsingName für die Dokumente-Bibliothek
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   if Succeeded(SHLoadLibraryFromParsingName( PWideChar(Edit1.Text),
                  STGM_READWRITE, IID_IShellLibrary, Pointer(FShellLibrary)) ) then
      ShowMessage('Success');
end;

end.

eholzer 6. Apr 2010 12:41

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
Das Thema würde mich auch interessieren.
Bei mir ist aber genauso - wird kompiliert, aber nicht gestartet.
Es muss an der Deklaration von SHLoadLibraryFromParsingName liegen.
Vielleicht hat jemand eine Idee?

Eric

HeikoAdams 6. Apr 2010 13:58

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
Mal ne vielleicht ganz blöde Frage, aber kann ich das IShellLibrary Interface auch unter Delphi 2006 nutzen? Hab bislang selber noch nichts mit Interfaces zu tun gehabt.

marcos 6. Apr 2010 20:51

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
Zitat:

Mal ne vielleicht ganz blöde Frage, aber kann ich das IShellLibrary Interface auch unter Delphi 2006 nutzen?
Ich glaube schon - vorausgesetzt du machst die notwendigen Deklarationen.

Zitat:

Leider das Programm kompiliert, aber startet auch nicht - keine Fehlermeldung.
Jetzt habe ich gemerkt, dass wenn ich die erzeugte Exe starte, dann bekomme ich die Meldung 'Der Prozedureinsprungspunkt "SHLoadLibraryFromParsingName" wurde in der DLL "shell32.dll" nicht gefunden'. Ich habe auch SHLoadLibraryFromParsingNameW und SHLoadLibraryFromParsingNameA mit gleichem Ergebnis probiert.

Hat jemand Ahnung, wo die Funktion versteckt ist? Es scheint, dass sie in shell32.dll nicht vorhanden ist.
Die Deklaration der Funktion sollte in Shobjidl.h vorhanden sein, wenn jemand die Datei hat - vielleicht ist dort was zu finden.

marcos

eholzer 8. Apr 2010 07:02

Re: Windows 7, wie bekomme ich IShellLibrary Interface
 
Man muss die Definitionen in Shobjidl.h finden und übersetzen.

Eric

Delphi-Quellcode:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellApi, ShlObj, ActiveX;

type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FShellLibrary: IShellLibrary;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}


function SHCreateLibrary(const riid: TIID; var ppv: Pointer): HRESULT;
begin
result := CoCreateInstance(CLSID_ShellLibrary, nil, CLSCTX_INPROC_SERVER,
IID_IShellLibrary, Pointer(ppv) ) ;
end;

function SHLoadLibraryFromParsingName( libraryParsingName: PWideChar;
stgmFlags: dword; const riid: TIID; var ppv: IShellLibrary): HResult;
var libraryFilePidl: PItemIDList;
libraryFileShellItem: IShellItem;
shellLibrary: IShellLibrary;
attributes: dword;

begin
attributes := 0;
result := SHILCreateFromPath(libraryParsingName,libraryFilePidl, attributes );
if result = S_OK then begin
result := SHCreateItemFromIDList(libraryFilePidl, IID_IShellItem, Pointer(libraryFileShellItem) );
if result = S_OK then begin
result := SHCreateLibrary(IID_IShellLibrary, Pointer(shellLibrary) );
if result = S_OK then begin
result := shellLibrary.LoadLibraryFromItem(libraryFileShellItem, STGM_READWRITE );
if result = S_OK then
ppv := shellLibrary;
end;
end;
end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
CoInitialize(nil);
Edit1.Text := '::{031E4825-7B94-4DC3-B131-E946B44C8DD5}\Documents.library-ms';
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
CoUninitialize;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if Succeeded(SHLoadLibraryFromParsingName(PWideChar(Edit1.Text),STGM_READWRITE,IID_IShellLibrary, FShellLibrary )) then
ShowMessage('Success');

end;

end.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:19 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