name15 Posted November 27, 2009 Share Posted November 27, 2009 how can get Type of file like (pagefile.sys is System) (1.txt is Text Document) Link to comment Share on other sites More sharing options...
KaFu Posted November 27, 2009 Share Posted November 27, 2009 (edited) expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: KaFu Script Function: _WinAPI_SHGetFileInfo_TYPENAME #ce ---------------------------------------------------------------------------- ; http://www.autoitscript.com/forum/index.php?showtopic=105984 ; http://msdn.microsoft.com/en-us/library/bb762179(VS.85).aspx $tagSHFILEINFO = 'int hIcon;int iIcon;dword Attributes;wchar DisplayName[260];wchar TypeName[80]' Global Const $SHGFI_ATTR_SPECIFIED = 0x00020000 Global Const $SHGFI_ATTRIBUTES = 0x00000800 Global Const $SHGFI_DISPLAYNAME = 0x00000200 Global Const $SHGFI_EXETYPE = 0x00002000 Global Const $SHGFI_ICON = 0x00000100 Global Const $SHGFI_ICONLOCATION = 0x00001000 Global Const $SHGFI_LARGEICON = 0x00000000 Global Const $SHGFI_LINKOVERLAY = 0x00008000 Global Const $SHGFI_OPENICON = 0x00000002 Global Const $SHGFI_OVERLAYINDEX = 0x00000040 Global Const $SHGFI_PIDL = 0x00000008 Global Const $SHGFI_SELECTED = 0x00010000 Global Const $SHGFI_SHELLICONSIZE = 0x00000004 Global Const $SHGFI_SMALLICON = 0x00000001 Global Const $SHGFI_SYSICONINDEX = 0x00004000 Global Const $SHGFI_TYPENAME = 0x00000400 Global Const $SHGFI_USEFILEATTRIBUTES = 0x00000010 Global Const $dwFILE_ATTRIBUTE_NORMAL = 0x80 $bFirstExtFound = False ; first key in my reg does NOT start with '.' but with '!', that's why to search for first '.' found $i = 1 ; counter for reg key enumeration while 1 $sExtensionFromReg = RegEnumKey('HKCR\', $i) ; enum possible extensions from registry if @error then exitloop if StringLeft($sExtensionFromReg, 1) <> '.' AND $bFirstExtFound = True then ExitLoop ; last extension found in reg, exitloop if StringLeft($sExtensionFromReg, 1) = '.' then $bFirstExtFound = True ConsoleWrite($sExtensionFromReg & @tab & " => " & @tab & _WinAPI_ShellGetFileInfo_TYPENAME($sExtensionFromReg,BitOR($SHGFI_USEFILEATTRIBUTES,$SHGFI_TYPENAME)) & @crlf) endif $i += 1 wend Func _WinAPI_ShellGetFileInfo_TYPENAME($sPath, $iFlags, $iAttributes = 0x80) Local $tSHFILEINFO = DllStructCreate($tagSHFILEINFO) Local $Ret = DllCall('shell32.dll', 'ptr', 'SHGetFileInfoW', 'wstr', $sPath, 'dword', $iAttributes, 'ptr', DllStructGetPtr($tSHFILEINFO), 'int', DllStructGetSize($tSHFILEINFO), 'int', $iFlags) If @error Then Return SetError(1, 0, 0) EndIf Return DllStructGetData($tSHFILEINFO,5) EndFunc ;==>_WinAPI_ShellGetFileInfo Edited November 27, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
funkey Posted November 27, 2009 Share Posted November 27, 2009 ConsoleWrite(_GetFileDesc("info.txt") & @LF) Func _GetFileDesc($sFilename) ;funkey Local $ext = StringTrimLeft($sFilename, StringInStr($sFilename, ".", 0, -1) - 1) Return RegRead("HKCR" & "\" & RegRead("HKCR" & "\" & $ext, ""), "") EndFunc Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
hxhjx Posted November 27, 2009 Share Posted November 27, 2009 well i would use a combination of StringRegExp ( "test", "pattern" [, flag ] [, offset ] ] ) and the file name Link to comment Share on other sites More sharing options...
KaFu Posted November 27, 2009 Share Posted November 27, 2009 Found issue, corrected first post, now works as a charme ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 27, 2009 Moderators Share Posted November 27, 2009 name15,I have sometimes used the TrID utility to ID files from apps not installed on my machine - it is free and pretty accurate. You can find out about it here.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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