AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Windows 7, wie bekomme ich IShellLibrary Interface
Thema durchsuchen
Ansicht
Themen-Optionen

Windows 7, wie bekomme ich IShellLibrary Interface

Ein Thema von marcos · begonnen am 5. Apr 2010 · letzter Beitrag vom 8. Apr 2010
Antwort Antwort
marcos

Registriert seit: 6. Mai 2006
50 Beiträge
 
#1

Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 5. Apr 2010, 11:37
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
  Mit Zitat antworten Zitat
Benutzerbild von implementation
implementation

Registriert seit: 5. Mai 2008
940 Beiträge
 
FreePascal / Lazarus
 
#2

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 5. Apr 2010, 12:30
Zitat von marcos:
Pointer(myhellLibrary)
Ich bin mir sicher, dass dort das Problem liegen wird. Prüf mal, was rauskommt.

Zitat von marcos:
aber das scheint nicht zu funktionieren.
Genauer geht's nicht?

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

Registriert seit: 1. Jan 2010
Ort: Leer
594 Beiträge
 
Delphi XE3 Professional
 
#3

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 5. Apr 2010, 12:33
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.
Lars
  Mit Zitat antworten Zitat
marcos

Registriert seit: 6. Mai 2006
50 Beiträge
 
#4

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 5. Apr 2010, 15:58
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.
  Mit Zitat antworten Zitat
eholzer

Registriert seit: 22. Okt 2009
51 Beiträge
 
#5

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 6. Apr 2010, 12:41
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
  Mit Zitat antworten Zitat
Benutzerbild von HeikoAdams
HeikoAdams

Registriert seit: 12. Jul 2004
Ort: Oberfranken
661 Beiträge
 
FreePascal / Lazarus
 
#6

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 6. Apr 2010, 13:58
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.
Jeder kann ein Held werden und Leben retten!
Einfach beim NKR oder der DKMS als Stammzellenspender registrieren! Also: worauf wartest Du noch?
  Mit Zitat antworten Zitat
marcos

Registriert seit: 6. Mai 2006
50 Beiträge
 
#7

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 6. Apr 2010, 20:51
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
  Mit Zitat antworten Zitat
eholzer

Registriert seit: 22. Okt 2009
51 Beiträge
 
#8

Re: Windows 7, wie bekomme ich IShellLibrary Interface

  Alt 8. Apr 2010, 07:02
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.
  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:18 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