Autor Beitrag
Snippy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Mo 14.10.02 14:37 
Hi!
Ich ab mal ne Frage:
Wie kann ich eine Verknüpfung der Datei *.exe ,die in dem Verzeichnis * gelegen ist, anlegen.

_________________
Carpe Diem!
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 14.10.02 15:52 
Schau mal in die FAQ. Dort befindet sich ein Beispiel!
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Di 15.10.02 12:12 
JO!
Das ist mir schonmal ne Hilfe, aber ich hab noch eine Frage dazu:

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:
Uses 
  ShlObj, ActiveX, ComObj; 

procedure CreateLink (Target, Args, WorkDir, ShortCutName: String); 
var 
  IObj: IUnknown; 
  Link: IShellLink; 
  IPFile: IPersistFile; 
  TargetW: WideString; 
begin 
  IObj := CreateComObject (CLSID_ShellLink); 
  Link := IObj as IShellLink; 
  IPFile := IObj as IPersistFile; 

  with Link do 
  begin 
    SetPath (PChar (Target)); 
    SetArguments (PChar (Args)); 
    SetShowCmd (SW_SHOWMINIMIZED); 
    SetWorkingDirectory (PChar (WorkDir)); 
  end

  TargetW := ShortCutName; 
  IPFile.Save (PWChar (TargetW), False); 
End;


Was bedeutet das "Args" und was muss ich bei "WorkDir" eingeben???


Und noch was!
ausblenden Delphi-Quelltext
1:
CreateLink ('c:\test.txt''''''d:\test.lnk');					

Ist das erste, die Datei , mit der die Verknüpfund angelegt werden soll und das Zweite, der Pfad, wo die Verknüpfung hinkopiert werden soll??

Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt

_________________
Carpe Diem!
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 15.10.02 12:48 
Args = Arguments; Kommandozeilenparameter - in deinem Fall nicht erforderlich. Sinnvoll bei EXE-Dateien u.ä., die mit speziellen Parametern gestartet werden sollen.

WorkDir = Working directory; Arbeitsverzeichnis - in deinem Fall auch nicht erforderlich. Eigentlich nur nötig, wenn dein Programm auf ein bestimmtes Verzeichnis zugreifen soll - eben das Arbeitsverzeichnis mit Konfig-Dateien usw.
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Di 15.10.02 14:45 
Sorry aber ich kriegs nicht gebacken!!!!! :oops:

Kann mir nicht einer mal den genauen sourcecode geben, wenn ich von der datei " Test.exe" in dem Verzeichnis "D:\" eine Verknüpfung namens "Test.ink" in dem Verzeichnis "E:\" anlegen will???

_________________
Carpe Diem!
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Di 15.10.02 15:37 
Hi

ausblenden Quelltext
1:
CreateLink ('D:\Test.exe', '', '', 'E:\test.lnk');					


Argumente und sowas brauchst du nicht

cu

Onz


Zuletzt bearbeitet von Moritz M. am Mi 16.10.02 14:15, insgesamt 1-mal bearbeitet
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Di 15.10.02 15:51 
Hab ich schon probiert, aber das geht nicht!!!
der erkennt "CreatLink" nicht!!!!?????!!!!!!?????!!!!!!

_________________
Carpe Diem!
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Di 15.10.02 15:58 
Hi

du must auf über dem aufruf noch die funktion definieren und die drei sachen in due uses liste eintragen. den code der funktion findest du weiter oben

cu

Onz
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 15.10.02 17:28 
Snippy hat folgendes geschrieben:
der erkennt "CreatLink" nicht!

Dann versuch es mal mit "CreateLink"!

Gruß
TINO
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Di 15.10.02 17:41 
Hi

hast du auch die funktion eingefügt und die sachen in die uses list eingetragen?

cu

Onz
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Di 15.10.02 17:50 
HÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?????????????

Kann mir nicht einer ma ein GENAUES Beispiel geben???

_________________
Carpe Diem!
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Di 15.10.02 17:56 
Hi

Nun dann wollen wir mal eine genau Anleitung schreiben:
1) Du öffnest ein neues Projekt
2) Du scrollst in Unit1 zur Useslist(ziemlich weit oben) und fügst dort vor dem Strichpunkt ( ; ) folgendes ein:
ausblenden Delphi-Quelltext
1:
,ShlObj, ActiveX, ComObj					

3) Du fügst dieses dort ein, wo die Funktionen und Prozeduren stehen:
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:
 procedure CreateLink (Target, Args, WorkDir, ShortCutName: String); 
var 
  IObj: IUnknown; 
  Link: IShellLink; 
  IPFile: IPersistFile; 
  TargetW: WideString; 
begin 
  IObj := CreateComObject (CLSID_ShellLink); 
  Link := IObj as IShellLink; 
  IPFile := IObj as IPersistFile; 

  with Link do 
  begin 
    SetPath (PChar (Target)); 
    SetArguments (PChar (Args)); 
    SetShowCmd (SW_SHOWMINIMIZED); 
    SetWorkingDirectory (PChar (WorkDir)); 
  end

  TargetW := ShortCutName; 
  IPFile.Save (PWChar (TargetW), False); 
End;


4) Du schreibst in irgendeine Prozedur oder Funktion, DIE UNTER DER CreateLink PROZEDURE LIKEN MUSS, folgendes ein um eine Verknüpfung der Datei C:\Programme\test.exe nach C:\Windows\Desktop anzulegen:
ausblenden Delphi-Quelltext
1:
CreateLink ('C:\Programme\test.exe''''''C:\Windows\Desktop\verknüpfung.lnk');					


Nun bist du fertig und alles müsste gehen. Falls du es immernochnicht schaffst schreib ich dir ein Beispielprojekt.

cu

Onz

Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt


Zuletzt bearbeitet von Moritz M. am Mi 16.10.02 14:10, insgesamt 1-mal bearbeitet
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Mi 16.10.02 12:47 
HI!
Eine Frage hab ich noch!
Soll der Code unter Nummer 3 unter die Prozedur die bei mir lautet:

procedure TForm1.Button1Click(Sender: TObject);???

_________________
Carpe Diem!
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Mi 16.10.02 12:55 
Super!!!!
Die obere Frage hat sich erübrigt, denn ich habs hinbekommen!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :D :D :D :D :D

VIELEN DANK AN ALLE, DIE MIR SO FLEIßIG GEHOLFEN HABEN!!!!!!!!!!!

Aber ein Problem ergibt sich noch :lol: :

Ich kann die Verknüpfung nicht öffnen!!!!
Dann kommt das Fenster "Öffnen mit..."
Wie kann ich das Problem noch beheben???

_________________
Carpe Diem!
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mi 16.10.02 14:10 
Hi

Oha. So Sorry. Ich hab nen Fehler gemacht!! :oops:
Der Aufruft muss natürlich
ausblenden Quelltext
1:
CreateLink ('D:\Test.exe', '', '', 'E:\test.lnk');					


heißten. die endung .ink gibts nicht. Ich verwechsle dass immer :evil: :wink:

nun müste es gehen

cu

Onz
Snippy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61



BeitragVerfasst: Mi 16.10.02 17:01 
VIIIIIIIIEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLEEEEEEEEEEEENNNNNNN
DANK!!!!!!!!!!!!!!!!!!!!!!!!

Besonders an dich Onz :D

Ihr habt mir sehr geholfen und jetzt geht es!!!!!!!!!
JJJJJJUUUUUUUUUUUUUUHHHHHHHHHHHHUUUUUUUUU

Nochmals vielen Dank!!!

_________________
Carpe Diem!
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mi 16.10.02 18:52 
Hi

Gerne geschehen... :P :P :P

Viel Spaß noch beim Programmieren

cu

Onz