Autor Beitrag
Jakane
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 257



BeitragVerfasst: Mi 18.05.11 10:16 
Hallo liebe Delphi-Helfer :)

Ich möchte mittels meinem Programm eine relativ komplette Ordner-Struktur automatisch aufbauen. Hab dabei aber 2 kleine Probleme:

1. Wie erstellt man (wenn's geht mit OpenDialog) eine Verknüpfung eines vorbestimmten Ordners (zB: \Neuer testOrdner\Test) und
2. Wie finde ich das Desktop-Verzeichnis eines beliebigen PC's um dort Ordner oder Verknüpfungen abzulegen :)

Danke für die Hilfen :)
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 18.05.11 11:07 
Hallo,

bitte erstelle für jede deiner Fragen ein separates Topic, da die Diskussion mehrerer Fragen in einem Topic für gewöhnlich für Verwirrung und Durcheinander sorgt.

Mindestens für 2. wirst du mit der Forensuche erfolgreich sein ;)
Entscheide dich bitte für eine Frage, die hier diskutiert werden soll und erstelle ggf. ein zweites Thema für die andere.

Viele Grüße,
Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Jakane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 257



BeitragVerfasst: Mi 18.05.11 12:31 
Für mich hängt beides zusammen :(

Aber 1. die Verknüpfung erstellen ist mir vorerst wichtiger.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.05.11 16:40 
Moin und :welcome: im Forum!

user profile iconJakane hat folgendes geschrieben Zum zitierten Posting springen:
Für mich hängt beides zusammen
Ist aber thematisch was ganz anders. :nixweiss:

user profile iconJakane hat folgendes geschrieben Zum zitierten Posting springen:
Aber 1. die Verknüpfung erstellen ist mir vorerst wichtiger.
Such mal nach Suche in: Delphi-Forum, Delphi-Library ISHELLLINK, dann solltest du so was ähnliches finden. :lupe: :les: :think:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.

Für diesen Beitrag haben gedankt: Jakane
Jakane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 257



BeitragVerfasst: Do 19.05.11 09:24 
Ich versteh die in dem Thema beschriebene Funktion nicht :(
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 19.05.11 09:41 
user profile iconJakane hat folgendes geschrieben Zum zitierten Posting springen:
Ich versteh die in dem Thema beschriebene Funktion nicht :(

Und jetzt? Wie wäre es, wenn du uns sagst, was du nicht verstehst?
Jakane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 257



BeitragVerfasst: Do 19.05.11 10:19 
:cry:
nun, das einzigste was ich aus der funktion lesen kann ist das da 2 if funktionen drin sind, alles andere versteh ich nicht :cry:

hatte gehoft es gibt ein einfacheren weg eine verknüpfung zu machen
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 19.05.11 10:57 
Wo liegt das Problem? Die Funktion in deine .pas-Datei kopieren.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
function CreateLink(const AFilename, ALNKFilename, ADescription, AArgument: string) : Boolean;
var
  psl : IShellLink;
  ppf : IPersistFile;
  wsz : PWideChar;
begin
  result:=false;
  if SUCCEEDED(CoCreateInstance(CLSID_ShellLink, nil,
  CLSCTX_inPROC_SERVER, IID_IShellLinkA, psl)) then
  begin
    psl.SetPath(PChar(AFilename));
    psl.SetDescription(PChar(ADescription));
    psl.SetWorkingDirectory(PChar(ExtractFilePath(AFilename)));
    psl.SetArguments(PChar(AArgument));
    if SUCCEEDED(psl.QueryInterface(IPersistFile, ppf)) then
    begin
      GetMem(wsz, MAX_PATH*2);
      try
        MultiByteToWideChar(CP_ACP, 0, PChar(ALNKFilename), -1, wsz, MAX_PATH);
        ppf.Save(wsz, true);
        result:=true;
      finally
        FreeMem(wsz, MAX_PATH*2);
      end;
    end;
  end;
end;


Und in z. B. einem ButtonClick-Ereignis aufrufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if CreateLink('C:\programm.exe''Pfad-zum-Desktop\Programm.lnk''Beschreibung''ggf. Parameter'then
  ShowMessage('Link wurde erstellt')
else
  ShowMessage('Da lief was schief... :-(');
Jakane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 257



BeitragVerfasst: Do 19.05.11 11:13 
[Fehler] SetUp_01.pas(210): Undefinierter Bezeichner: 'IShellLink'
[Fehler] SetUp_01.pas(211): Undefinierter Bezeichner: 'IPersistFile'
[Fehler] SetUp_01.pas(215): Undefinierter Bezeichner: 'CoCreateInstance'
[Fehler] SetUp_01.pas(215): Undefinierter Bezeichner: 'CLSID_ShellLink'
[Fehler] SetUp_01.pas(216): Undefinierter Bezeichner: 'CLSCTX_inPROC_SERVER'
[Fehler] SetUp_01.pas(216): Undefinierter Bezeichner: 'IID_IShellLinkA'
[Fehler] SetUp_01.pas(218): Operator oder Semikolon fehlt
[Fehler] SetUp_01.pas(219): Operator oder Semikolon fehlt
[Fehler] SetUp_01.pas(220): Operator oder Semikolon fehlt
[Fehler] SetUp_01.pas(221): Operator oder Semikolon fehlt
[Fehler] SetUp_01.pas(222): ')' erwartet, aber Bezeichner 'QueryInterface' gefunden
[Fehler] SetUp_01.pas(227): Operator oder Semikolon fehlt

Das ist mein Problem bei Funktionen die ich nicht kenne und nicht verstehe :(
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 19.05.11 12:37 
Lösung: IShellLink im MSDN oder Delphi-Hilfe eingeben und schauen in welcher Datei das definiert ist. Glaube das war ShellAPI oder ShlObj. Alternativ im Forum danach suchen. Bisschen Eigeninitiative wäre schon angebracht!
Jakane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 257



BeitragVerfasst: Do 19.05.11 13:37 
Wenn meine Eigeninitiative Ergebnisse gehabt hätte, hätte ich kein Thema geschrieben, aber hier scheint man lieber zu meckern.

Danke, inzwischen hat mir ein Freund helfen können