Autor Beitrag
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 24.08.03 14:09 
Betrifft Win32 API und NT Native API

Download unter:
assarbad.net/stuff/!export/hardlink.ace
assarbad.net/stuff/!export/hardlink.rar
assarbad.net/stuff/!export/hardlink.zip

Der Code ist wahlweise unter BSDL oder LGPL zu benutzen!
LGPL wurde nur als Option angegeben um die Benutzung in unserem DP-Projekt DoubleKiller zu ermöglichen

Hiho,

ich habe die CreateHardLink API, welche mit Windows 2000 offiziell eingeführt wurde, komplett nachempfunden (in Delphi).
Will heißen, auch wenn der Code nicht identisch ist, macht er dennoch das Gleiche (wenn auch nicht das Selbe). Wohlgemerkt alle Fehlerrückgaben, die bei der orginalen Windows 2000 API zurückgegeben werden, sind identisch. Auch die Annahme von Parametern und Verarbeitung entspricht dem Original. Bei einigen Punkten habe ich einfach eine Native API genommen statt "per Hand" zu kopieren.
Es gelten die gleichen Einschränkungen und Features von CreateHardLinkW() in der Kernel32.dll in Windows 2000 wie CreateHardLinkW() in meiner Unit.
Einzig ein Kompilerschalter definiert ob die Funktion mit oder ohne STDCALL läuft. Standard ist ohne ... ich gehe davon aus, daß meine Funktionen nur unter Delphi und BCB benutzt werden.

Es werden keine Backup/Restore-Privilegien benötigt, wie bei der Methode mit den Backup-Streams ... daher komplett kompatibel mit der in Windows 2000 eingeführten gleichnamigen Funktion.
Außerdem ist die Funktion komplett kompatibel mit NT4 aufwärts (und NTFS). Ich habe eine ANSI und eine Unicode-Version implementiert. Würde man eine EXPORT-Klausel einfügen, könnte man die DLL auf jedem der aktuellen NT-Systeme (NT4/2K/XP/2K3) benutzen. Informationen zu Hardlinks gibts hier (von MS selbst im PSDK formuliert):

ausblenden volle Höhe 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:
28:
29:
30:
31:
32:
  Any directory entry for a file, whether created with CreateFile or
  CreateHardLink, is a hard link to the associated file. Additional hard links,
  created with the CreateHardLink function, allow you to have multiple directory
  entries for a file, that is, multiple hard links to the same file. These may
  be different names in the same directory, or they may be the same (or
  different) names in different directories. However, all hard links to a file
  must be on the same volume.
  Because hard links are just directory entries for a file, whenever an
  application modifies a file through any hard link, all applications using any
  other hard link to the file see the changes. Also, all of the directory
  entries are updated if the file changes. For example, if the file's size
  changes, all of the hard links to the file will show the new size.
  The security descriptor belongs to the file to which the hard link points.
  The link itself, being merely a directory entry, has no security descriptor.
  Thus, if you change the security descriptor of any hard link, you're actually
  changing the underlying file's security descriptor. All hard links that point
  to the file will thus allow the newly specified access. There is no way to
  give a file different security descriptors on a per-hard-link basis.
  This function does not modify the security descriptor of the file to be linked
  to, even if security descriptor information is passed in the
  lpSecurityAttributes parameter.
  Use DeleteFile to delete hard links. You can delete them in any order
  regardless of the order in which they were created.
  Flags, attributes, access, and sharing as specified in CreateFile operate on
  a per-file basis. That is, if you open a file with no sharing allowed, another
  application cannot share the file by creating a new hard link to the file.

  CreateHardLink does not work over the network redirector.

  Note that when you create a hard link on NTFS, the file attribute information
  in the directory entry is refreshed only when the file is opened or when
  GetFileInformationByHandle is called with the handle of the file of interest.


Zuletzt bearbeitet von Gast am Mo 25.08.03 21:35, insgesamt 1-mal bearbeitet
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 25.08.03 21:27 
Titel: @Mods
@Mods: habt ihr euch durchgelesen, was hier drin steht? Es ist zwar OpenSource ... es ist aber kein Programm. Also in diesem Sinne (und im Delphi-Sinne) kein Projekt!
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 25.08.03 21:33 
Na gut, egal ... vielleicht paßt es ja doch, wenn ich noch hinzufüge, daß es ein OS-Projekt gibt, welches die entsprechende Funktion verwendet ;) ... man könnte es als Beispiel nehmen. Es ist komplett Unicode-fähig!

assarbad.net/stuff/ln.ace
assarbad.net/stuff/ln.rar
assarbad.net/stuff/ln.zip

:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mo 25.08.03 22:59 
Wir sind gerade am Diskutieren, was wir mit Deinem Beitrag machen, keine Sorge. Aber soll das jetzt heißen, wir sollen es in OpenSource stellen, oder wie?
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 25.08.03 23:27 
Hehe ... jetzt hab ich es euch schwer gemacht, gelle ;) ...

Also die Unit an sich, würde ich (so wie ichs gemacht habe) unter die FAQ-Rubrik machen (in der DP ist es schon in der CodeLib). Hingegen das Programm würde natürlich am ehesten nach OpenSource passen.

Am sinnvollsten paßt aber beides zusammen ... deshalb entscheidet ihr doch einfach *g* ;)