Carlo84 Posted April 3, 2012 Share Posted April 3, 2012 Hello all, i was wondering how can i obtain a directory handle, i can get a real path of a file using _WinAPI_CreateFile to get file handle and GetFinalPathNameByHandle to get the actual path.I am working with junction points and am trying to get the actual path of directories rather then files, but i am unsure how to obtain a handle for directory if anyone could point me to the right way that would be great :-) _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 3, 2012 Share Posted April 3, 2012 Hello all, i was wondering how can i obtain a directory handle, i can get a real path of a file using _WinAPI_CreateFile to get file handle and GetFinalPathNameByHandle to get the actual path.I am working with junction points and am trying to get the actual path of directories rather then files, but i am unsure how to obtain a handle for directory if anyone could point me to the right way that would be great :-)Not sure I understand what you're talking about, do you mean you want to open a directory like the FileOpen() function, but instead of opening a file for modification you want to do this with a directory? or do you want to get the directory name that belongs to an already obtained handle fora fileobject handle? Link to comment Share on other sites More sharing options...
Carlo84 Posted April 3, 2012 Author Share Posted April 3, 2012 Not sure I understand what you're talking about, do you mean you want to open a directory like the FileOpen() function, but instead of opening a file for modification you want to do this with a directory? or do you want to get the directory name that belongs to an already obtained handle fora fileobject handle? from http://msdn.microsoft.com/en-us/library/aa364962%28VS.85%29.aspx hFile [in] A handle to a file or directory. basacally i want to use that function on a directory and not on a file, it does not take paths but handles, tbh i never heard of a directory handle, but since its in the description i hope it is possible. _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 3, 2012 Share Posted April 3, 2012 (edited) from http://msdn.microsoft.com/en-us/library/aa364962%28VS.85%29.aspx basacally i want to use that function on a directory and not on a file, it does not take paths but handles, tbh i never heard of a directory handle, but since its in the description i hope it is possible. I was just playing with this subject a while ago, there's a function wrapper for that API done by yashied, search the examples section for winapiex.au3 and it's there. ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetFinalPathNameByHandle ; Description....: Retrieves the final path of the specified file. ; Syntax.........: _WinAPI_GetFinalPathNameByHandle ( $hFile ) ; Parameters.....: $hFile - Handle to a file or directory whose path is to be retrieved. ; Return values..: Success - The path of the file. ; Failure - Empty string and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS code. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ ZwQueryInformationFile ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_GetFinalPathNameByHandle($hFile) Local $tFNI, $tIOSB, $Ret, $Length $tFNI = DllStructCreate('ulong;wchar[4096]') $tIOSB = DllStructCreate('ptr;ulong_ptr') $Ret = DllCall('ntdll.dll', 'uint', 'ZwQueryInformationFile', 'ptr', $hFile, 'ptr', DllStructGetPtr($tIOSB), 'ptr', DllStructGetPtr($tFNI), 'ulong', DllStructGetSize($tFNI), 'uint', 9) If @error Then Return SetError(1, 0, '') Else If $Ret[0] Then Return SetError(1, $Ret[0], '') EndIf EndIf $Length = DllStructGetData($tFNI, 1) If Not $Length Then Return SetError(2, 0, '') EndIf Return DllStructGetData(DllStructCreate('wchar[' & ($Length / 2) & ']', DllStructGetPtr($tFNI, 2)), 1) EndFunc ;==>_WinAPI_GetFinalPathNameByHandle Edited April 3, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
guinness Posted April 3, 2012 Share Posted April 3, 2012 ApudAngelorum, It's always best to post a link to the WinAPIEx thread, especially if you're going to start pulling out functions from it. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Skitty Posted April 3, 2012 Share Posted April 3, 2012 ApudAngelorum,It's always best to post a link to the WinAPIEx thread, especially if you're going to start pulling out functions from it.I didn't have the link, and it's not like i'm claiming it's mine either, I told him it's yashieds so no one thinks i'm plagiarizing stuff, and the reason I posted it was cause I actually already had a tab open in scite where I was playing with just that function in a script. Link to comment Share on other sites More sharing options...
Carlo84 Posted April 3, 2012 Author Share Posted April 3, 2012 Im sorry if you dont understand the question, i usually blame it on my poor English :-)The function i wrote is pretty much the same as you just posted, thats not the issue, the issue is how to use it on a directory and not a file.it asks for a directory handle.@guiness that UDF is here _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 4, 2012 Share Posted April 4, 2012 (edited) Im sorry if you dont understand the question, i usually blame it on my poor English :-) The function i wrote is pretty much the same as you just posted, thats not the issue, the issue is how to use it on a directory and not a file. it asks for a directory handle. @guiness that UDF is here I think I know what you're talking about now, maybe you can take apart this script I've been putting together these last few days. And sorry for the late reply, I thought someone would have helped you already, hope this solves your problem. Edited April 4, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
Carlo84 Posted April 4, 2012 Author Share Posted April 4, 2012 (edited) Thanks allot for trying to help :-) im not in need of process/window handles or anything, there are none, this is pure about files and directories. I wrote up a simple example script to explain my case. For anyone deciding to try it, be aware that it creates and deletes the folders "C:Junction" and "C:Truepath" #include <WinAPI.au3> Global $sTruepath = 'C:Truepath' Global $sJunctionPoint = 'C:Junction' DirCreate($sTruepath) ;Create the REAL directory. FileCreateNTFSLink($sTruepath, $sJunctionPoint) ;Create a Junction Point acting like the real directory, this is the path i cannot retrieve using "GetFinalPathNameByHandle" cause i cannot get a directory handle, how do i get a directory handle? FileWrite($sJunctionPoint & 'file.txt', '') ;lets create a file in the Junction point. $hFile = _WinAPI_CreateFile($sJunctionPoint & 'file.txt', 2) ; Getting a file handle is not so hard but we need a directory handle to use the function below on the directory instead of a file. MsgBox(64, 'Realpath', _WinAPI_GetFinalPathNameByHandle($hFile)) ;the result of using "$sJunctionPoint & 'file.txt'" should now equal "$sTruepath & 'file.txt'" and thats exactly what i need to do with directories and not files. cleanup() Func _WinAPI_GetFinalPathNameByHandle($hFile) Local $aResult = DllCall("kernel32.dll", "DWORD", "GetFinalPathNameByHandle", "handle", $hFile, "str", 0, "DWORD", 260, "DWORD", 0) If @error Then Return SetError(@error, @extended, 0) Return StringRegExpReplace($aResult[2], '(?i)(A[^a-z]*)', '') EndFunc ;==>_WinAPI_GetFinalPathNameByHandle Func cleanup() Dim $sTruepath, $sJunctionPoint DirRemove($sJunctionPoint, 0) DirRemove($sTruepath, 1) EndFunc ;==>cleanup I can see 2 outcomes to this, either it is possible to obtain a handle on a folder or it is not possible and i have to write a temp file to a junction folder just to see its true path. Alshough the msdn helpfile and even the script posted by ApudAngelorum suggest input of a directory handle. Edited April 4, 2012 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 4, 2012 Share Posted April 4, 2012 (edited) Thanks allot for trying to help :-) im not in need of process/window handles or anything, there are none, this is pure about files and directories. I wrote up a simple example script to explain my case. For anyone deciding to try it, be aware that it creates and deletes the folders "C:Junction" and "C:Truepath" #include <WinAPI.au3> Global $sTruepath = 'C:Truepath' Global $sJunctionPoint = 'C:Junction' DirCreate($sTruepath) ;Create the REAL directory. FileCreateNTFSLink($sTruepath, $sJunctionPoint) ;Create a Junction Point acting like the real directory, this is the path i cannot retrieve using "GetFinalPathNameByHandle" cause i cannot get a directory handle, how do i get a directory handle? FileWrite($sJunctionPoint & 'file.txt', '') ;lets create a file in the Junction point. $hFile = _WinAPI_CreateFile($sJunctionPoint & 'file.txt', 2) ; Getting a file handle is not so hard but we need a directory handle to use the function below on the directory instead of a file. MsgBox(64, 'Realpath', _WinAPI_GetFinalPathNameByHandle($hFile)) ;the result of using "$sJunctionPoint & 'file.txt'" should now equal "$sTruepath & 'file.txt'" and thats exactly what i need to do with directories and not files. cleanup() Func _WinAPI_GetFinalPathNameByHandle($hFile) Local $aResult = DllCall("kernel32.dll", "DWORD", "GetFinalPathNameByHandle", "handle", $hFile, "str", 0, "DWORD", 260, "DWORD", 0) If @error Then Return SetError(@error, @extended, 0) Return StringRegExpReplace($aResult[2], '(?i)(A[^a-z]*)', '') EndFunc ;==>_WinAPI_GetFinalPathNameByHandle Func cleanup() Dim $sTruepath, $sJunctionPoint DirRemove($sJunctionPoint, 0) DirRemove($sTruepath, 1) EndFunc ;==>cleanup I can see 2 outcomes to this, either it is possible to obtain a handle on a folder or it is not possible and i have to write a temp file to a junction folder just to see its true path. Alshough the msdn helpfile and even the script posted by ApudAngelorum suggest input of a directory handle. I don't know where you got the impression that the code I posted gets handles to windows or has anything to do at all with windows, but now that I look at your example I'm pretty sure the solution you need is in the script previously posted above. And you're example is flawed, use yashieds version of the function. ther's no need to make it overly complicated. #Include <WinAPI.au3> Global $sTruepath = 'C:Truepath' Global $sJunctionPoint = 'C:Junction' DirCreate($sTruepath) ;Create the REAL directory. FileCreateNTFSLink($sTruepath, $sJunctionPoint) ;Create a Junction Point acting like the real directory, this is the path i cannot retrieve using "GetFinalPathNameByHandle" cause i cannot get a directory handle, how do i get a directory handle? FileWrite($sJunctionPoint & 'file.txt', '') ;lets create a file in the Junction point. $hFile = _WinAPI_CreateFile($sJunctionPoint & 'file.txt', 2) ; Getting a file handle is not so hard but we need a directory handle to use the function below on the directory instead of a file. MsgBox(64, 'Realpath', _WinAPI_GetFinalPathNameByHandle($hFile)) ;the result of using "$sJunctionPoint & 'file.txt'" should now equal "$sTruepath & 'file.txt'" and thats exactly what i need to do with directories and not files. cleanup() Func _WinAPI_GetFinalPathNameByHandle($hFile) Local $tFNI, $tIOSB, $Ret, $Length $tFNI = DllStructCreate('ulong;wchar[4096]') $tIOSB = DllStructCreate('ptr;ulong_ptr') $Ret = DllCall('ntdll.dll', 'uint', 'NtQueryInformationFile', 'ptr', $hFile, 'ptr', DllStructGetPtr($tIOSB), 'ptr', DllStructGetPtr($tFNI), 'ulong', DllStructGetSize($tFNI), 'uint', 9) If @error Then Return SetError(1, 0, '') Else If $Ret[0] Then Return SetError(1, $Ret[0], '') EndIf EndIf $Length = DllStructGetData($tFNI, 1) If Not $Length Then Return SetError(2, 0, '') EndIf Return DllStructGetData(DllStructCreate('wchar[' & ($Length / 2) & ']', DllStructGetPtr($tFNI, 2)), 1) EndFunc ;==>_WinAPI_GetFinalPathNameByHandle Func cleanup() Dim $sTruepath, $sJunctionPoint DirRemove($sJunctionPoint, 0) DirRemove($sTruepath, 1) EndFunc ;==>cleanup Also, here is a version that will include the drive path... expandcollapse popup#include <WinAPI.au3> Global $sTruepath = 'C:Truepath' Global $sJunctionPoint = 'C:Junction' DirCreate($sTruepath) ;Create the REAL directory. FileCreateNTFSLink($sTruepath, $sJunctionPoint) ;Create a Junction Point acting like the real directory, this is the path i cannot retrieve using "GetFinalPathNameByHandle" cause i cannot get a directory handle, how do i get a directory handle? FileWrite($sJunctionPoint & 'file.txt', '') ;lets create a file in the Junction point. $hFile = _WinAPI_CreateFile($sJunctionPoint & 'file.txt', 2) ; Getting a file handle is not so hard but we need a directory handle to use the function below on the directory instead of a file. Local $struct = DllStructCreate("char[255];") Local $temp = DriveGetDrive("ALL") Local $drivesinfo[UBound($temp) - 1][2] For $I = 0 To UBound($drivesinfo) - 1 $drivesinfo[$I][0] = $temp[$I + 1] DllCall('kernel32', "dword", "QueryDosDevice", "str", $drivesinfo[$I][0], "ptr", DllStructGetPtr($struct), "dword", 255) $drivesinfo[$I][1] = DllStructGetData($struct, 1) Next Local $PUBLIC_OBJECT_TYPE_INFORMATION = "ushort Length;" & _ "ushort MaximumLength;" & _ "ptr Buffer;" & _ ;UNICODE_STRING struct "wchar Reserved[260];" Local $poti = DllStructCreate($PUBLIC_OBJECT_TYPE_INFORMATION) DllCall('ntdll', "ulong", "NtQueryObject", "ptr", $hFile, "int", 1, "ptr", DllStructGetPtr($poti), "ulong", DllStructGetSize($poti), "ulong*", "") $devicestr = DllStructCreate("wchar[" & Ceiling(DllStructGetData($poti, "Length") / 2) & "];", DllStructGetData($poti, "buffer")) $devicestr = DllStructGetData($devicestr, 1) For $y = 0 To UBound($drivesinfo) - 1 If StringLeft($devicestr, StringLen($drivesinfo[$y][1])) = $drivesinfo[$y][1] Then $Solid = StringUpper($drivesinfo[$y][0]) & StringTrimLeft($devicestr, StringLen($drivesinfo[$y][1])) ExitLoop EndIf Next MsgBox(64, 'Realpath', $Solid) ;the result of using "$sJunctionPoint & 'file.txt'" should now equal "$sTruepath & 'file.txt'" and thats exactly what i need to do with directories and not files. cleanup() Func cleanup() Dim $sTruepath, $sJunctionPoint DirRemove($sJunctionPoint, 0) DirRemove($sTruepath, 1) EndFunc ;==>cleanup I'd also like to mention that file object handles and handles to directories are the same... Under windows xp their value is 28, this is same for directories, using the same code above will get you name of directory/file that belongs to object handle, that is where I think you're getting things mixed up. Edited April 4, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
Carlo84 Posted April 4, 2012 Author Share Posted April 4, 2012 (edited) The version you posted is missing the drive my function returns "'C:Truepath'file.txt" whereas his returns ":Truepath'file.txt" but i will probably use his and edit it some or just workout mine (was just temporarily no use to work out entire functions if you cannot use them) Anyways bout the file you uploaded it seems to check a process for handles and information at least thats what it says in the description. im unsure how that would give me a folders handle as theres no process. Im sorry the comments just dont explain to me what it infact does. Edited April 4, 2012 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 4, 2012 Share Posted April 4, 2012 (edited) The version you posted is missing the drive my function returns "'C:Truepath'file.txt" whereas his returns ":Truepath'file.txt"but i will probably use his and edit it some or just workout mine (was just temporarily no use to work out entire functions if you cannot use them)Anyways bout the file you uploaded it seems to check a process for handles and information at least thats what it says in the description. im unsure how that would give me a folders handle as theres no process.Im sorry the comments just dont explain to me what it infact does.See second version below first for included drive path, and on my PC your function returned 0, but after looking at your example again I noticed that you ask "the result of using "$sJunctionPoint & 'file.txt'" should now equal "$sTruepath & 'file.txt'" and thats exactly what i need to do with directories and not files.".Are you saying you want to get the handle to the directory the text file is in?Edit: Also, that's an API typically used in kernel mode, what you wan't is the NtOpenFile equivalent, but both will work anyway but proper is proper... Edited April 4, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
Carlo84 Posted April 4, 2012 Author Share Posted April 4, 2012 (edited) Are you saying you want to get the handle to the directory the text file is in? yes thats exactly what im after everything i did to that file i want to do to the directory instead as there might not be any files inside the directories [Edit] Edit: Also, that's an API typically used in kernel mode, what you wan't is the NtOpenFile equivalent, but both will work anyway but proper is proper... ah thank you so much :-) PS: are you by any chance running XP? Edited April 4, 2012 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 4, 2012 Share Posted April 4, 2012 yes thats exactly what im after everything i did to that file i want to do to the directory instead as there might not be any files inside the directoriesI'm sorry guy, but you're really confusing me right now (probably cause I'm high), are you saying you just want a handle to the directory or that you want to write the data to the directory via an open handle? because in the example you posted, the data you write to the file is written to both text files since they're the same files and one of them is just a link to the real one, but you know that already right? And also, you cannot write any data to the directory as you would to a text file if that is what you're getting at. Link to comment Share on other sites More sharing options...
Carlo84 Posted April 4, 2012 Author Share Posted April 4, 2012 I'm sorry guy, but you're really confusing me right now (probably cause I'm high), are you saying you just want a handle to the directory or that you want to write the data to the directory via an open handle? because in the example you posted, the data you write to the file is written to both text files since they're the same files and one of them is just a link to the real one, but you know that already right? And also, you cannot write any data to the directory as you would to a text file if that is what you're getting at.lol yes i only want the handle.forget about the file _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 4, 2012 Share Posted April 4, 2012 lol yes i only want the handle. forget about the file well, why not just open a hndle to the directory then? I don't really see the problem... expandcollapse popupGlobal $sTruepath = 'C:Truepath' Global $sJunctionPoint = 'C:Junction' DirCreate($sTruepath) ;Create the REAL directory. FileCreateNTFSLink($sTruepath, $sJunctionPoint) ;Create a Junction Point acting like the real directory, this is the path i cannot retrieve using "GetFinalPathNameByHandle" cause i cannot get a directory handle, how do i get a directory handle? FileWrite($sJunctionPoint & 'file.txt', '') ;lets create a file in the Junction point. $hFile = DllCall("kernel32", "handle", "CreateFileW", _ "wstr", $sJunctionPoint, _ "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _ "int", 0x02000000, _ "ptr", 0) ; Getting a file handle is not so hard but we need a directory handle to use the function below on the directory instead of a file. $hFile = $hFile[0] Local $struct = DllStructCreate("char[255];") Local $temp = DriveGetDrive("ALL") Local $drivesinfo[UBound($temp) - 1][2] For $I = 0 To UBound($drivesinfo) - 1 $drivesinfo[$I][0] = $temp[$I + 1] DllCall('kernel32', "dword", "QueryDosDevice", "str", $drivesinfo[$I][0], "ptr", DllStructGetPtr($struct), "dword", 255) $drivesinfo[$I][1] = DllStructGetData($struct, 1) Next Local $PUBLIC_OBJECT_TYPE_INFORMATION = "ushort Length;" & _ "ushort MaximumLength;" & _ "ptr Buffer;" & _ ;UNICODE_STRING struct "wchar Reserved[260];" Local $poti = DllStructCreate($PUBLIC_OBJECT_TYPE_INFORMATION) DllCall('ntdll', "ulong", "NtQueryObject", "ptr", $hFile, "int", 1, "ptr", DllStructGetPtr($poti), "ulong", DllStructGetSize($poti), "ulong*", "") $devicestr = DllStructCreate("wchar[" & Ceiling(DllStructGetData($poti, "Length") / 2) & "];", DllStructGetData($poti, "buffer")) $devicestr = DllStructGetData($devicestr, 1) For $y = 0 To UBound($drivesinfo) - 1 If StringLeft($devicestr, StringLen($drivesinfo[$y][1])) = $drivesinfo[$y][1] Then $Solid = StringUpper($drivesinfo[$y][0]) & StringTrimLeft($devicestr, StringLen($drivesinfo[$y][1])) ExitLoop EndIf Next ConsoleWrite("File handle from junction point = " & $Solid & @CR) cleanup() Func cleanup() Dim $sTruepath, $sJunctionPoint DirRemove($sJunctionPoint, 0) DirRemove($sTruepath, 1) EndFunc ;==>cleanup Link to comment Share on other sites More sharing options...
Carlo84 Posted April 4, 2012 Author Share Posted April 4, 2012 (edited) YES!!!! right before i read your post i was reading this one funny how the solution ended up to be the very first function i have tried on this issue jsut without the FILE_FLAG_BACKUP_SEMANTICSWorks with my own function too (ps wasnt flawed it just requires Vista and higer)I have been working with Autoit for years and rarely ask questions unless im really stuck, and figuring out the real path of junction points has been a real pain in the ass, been well over a week since i started trying this and google wasnt my friend :-pThank you very much for all your help ApudAngelorumwell, why not just open a hndle to the directory then? I don't really see the problem...that was the question.. how to do that :-p Edited April 4, 2012 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Skitty Posted April 4, 2012 Share Posted April 4, 2012 (edited) Then your question should have been phrased "Get NTFS hardlink path" no? Also, I'd assume using a function that works on a wider spectrum of operating systems would be in good practice unless you're not going to use this function on various operating systems, then from that perspective, it is flawed. Edited April 4, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
guinness Posted April 4, 2012 Share Posted April 4, 2012 (edited) I didn't have the link, and it's not like i'm claiming it's mine either, I told him it's yashieds so no one thinks i'm plagiarizing stuff, and the reason I posted it was cause I actually already had a tab open in scite where I was playing with just that function in a script.It wasn't about plagiarism, but reducing the amount of reports Yashied might receive in the future, if he ever decides to update that particular function. What tends to happen is people will copy the code above, later on it stops working and then report in Yashied's WinAPIEx thread that it no longer works, but yet he updated that function months before.Edit: Fixed disregard for genitive case. Edited April 4, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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