UEZ Posted January 7, 2011 Share Posted January 7, 2011 @Cars0n66: I think you misunderstood the question from SoulA! Read it again carefully! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Ascend4nt Posted January 11, 2011 Share Posted January 11, 2011 I knew I already read it somewhere, found the MSDN article again: "There are three types of file links supported in the NTFS file system: hard links, junctions, and symbolic links." Hey KaFu, thanks for the link. Had time recently to revisit this and it makes sense to me now. Hard Links are no different than the original file itself basically. Both point to the same record in the MFT, and deleting the 'original' doesn't affect the hard link, just the 'link count'. To that end I've created the following function which can be used to find out if there are hardlinks (index[6] = # of links). I've also added URL's for info on hard links and whatnot (more for my benefit I guess than anyone else's): expandcollapse popup#include <WinAPI.au3> ; =================================================================================================================== ; Func _FileGetInfoByOpening($sFile) ; ; Gets file attribute & size information by opening a file. Also gets hard-link counts and other stuff. ; ; NOTES: ; - [Hard Links] (8th element of return structure): ; A few good references on Hard Links (vs Symbolic Links and Junctions): ; MSDN: 'Hard Links and Junctions (Windows)' [also links to 'Creating Symbolic Links (Windows)' article]: ; http://msdn.microsoft.com/en-us/library/aa365006%28v=VS.85%29.aspx ; FlexHex: 'NTFS Hard Links, Directory Junctions, and Windows Shortcuts': ; http://www.flexhex.com/docs/articles/hard-links.phtml ; Wikipedia: 'Hard Link': ; http://en.wikipedia.org/wiki/Hard_link ; ; *Ultimately a Hard Link is the same as the actual original file listing - both point to one file* ; (deleting the 'original' will not delete the hard link, as they both are just 'pointers' to an MFT entry) ; ; - [FileIndex]: ; MSDN: ; 'The [FileIndex] identifier ... and the volume serial number uniquely identify a file on a single computer. ; To determine whether two open handles represent the same file, combine the identifier and the ; volume serial number for each file and compare them.' ; ; Returns: ; Success: An 8-element array of File Info (@error=0): ; [0] = File Attributes ; [1] = Creation Time (as 64-bit FileTime) ; [2] = Last-Access Time (as 64-bit FileTime) ; [3] = Last-Write Time (as 64-bit FileTime) ; [4] = Volume Serial Number (MSDN: 'The serial number of the volume that contains a file.') ; [5] = File Size (in bytes) ; [6] = Number of Links to this file (>1 means there is at least 1 hardlink created) ; [7] = File Index (unique identifier - see above MSDN info) ; Failure: '' and @error set: ; @error = -1 = _WinAPI_CreateFile() error - call GetLastError for more info ; @error = 1 = Invalid parameter ; @error = 2 = DLLCall error. @extended = actual DLLCall error-code (see AutoIt Help) ; @error = 3 = API call returned failure ; ; Author: Ascend4nt ; =================================================================================================================== Func _FileGetInfoByOpening($sFile) If Not IsString($sFile) Or $sFile='' Then Return SetError(1,0,-1) Local $aRet,$hFile,$iErr,$stBHFileInfo $hFile=_WinAPI_CreateFile($sFile,2,2,6) If $hFile=0 Then Return SetError(-1,@error,'') ; BY_HANDLE_FILE_INFORMATION: dwFileAttributes,ftCreationTime,ftLastAccessTime,ftLastWriteTime, ; dwVolumeSerialNumber,nFileSizeHigh,nFileSizeLow,nNumberOfLinks,nFileIndexHigh,nFileIndexLow $stBHFileInfo=DllStructCreate('align 4;dword;uint64;uint64;uint64;dword;dword;dword;dword;dword;dword') $aRet=DllCall('kernel32.dll','bool','GetFileInformationByHandle','handle',$hFile,'ptr',DllStructGetPtr($stBHFileInfo)) $iErr=@error _WinAPI_CloseHandle($hFile) If $iErr Then Return SetError(2,$iErr,'') If Not $aRet[0] Then Return SetError(3,0,'') ; For converting backwards split 64-bit values FileSize and FileIndex Local $stTo64=DllStructCreate('uint64'),$stTwo32=DllStructCreate('dword[2]',DllStructGetPtr($stTo64)) Dim $aRet[8] For $i=0 To 4 $aRet[$i]=DllStructGetData($stBHFileInfo,$i+1) Next ; FileSize next DllStructSetData($stTwo32,1,DllStructGetData($stBHFileInfo,7),1) DllStructSetData($stTwo32,1,DllStructGetData($stBHFileInfo,6),2) $aRet[5]=DllStructGetData($stTo64,1) $aRet[6]=DllStructGetData($stBHFileInfo,8) ; nNumberOfLinks - If >1, there are Hard Links ; FileIndex next DllStructSetData($stTwo32,1,DllStructGetData($stBHFileInfo,10),1) DllStructSetData($stTwo32,1,DllStructGetData($stBHFileInfo,9),2) $aRet[7]=DllStructGetData($stTo64,1) Return $aRet EndFunc Thanks again! My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
KaFu Posted January 11, 2011 Share Posted January 11, 2011 I thank YOU m8, for another great piece of code I can use for SMF ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now