Jump to content

Help with file type icons being read


Recommended Posts

PROJECT BACKGROUND

I recently found out how to map a SkyDrive account to a network drive. However, SkyDrive does not allow copying of certain file types. I'm writing a utility that copies the files as ".bak" files to bypass this block. I am running Windows 7 Professional with MS Office 2010.

THE POINT

I want to display file type icons next to the copying progress.

In the registry, the file type icon is stored in "HKCR\FileType\DefaultIcon\DEFAULT", where "FileType" is a string stored in "HKCR\(insert file extension here)\DEFAULT". Final output is in the format "C:\folder\icons.exe,3".

Examples:

For INI files, the output is imageres.dll,-69 and the icon shows correctly.

For DOC files, the output is C:\...\wordicon.exe,1 and the first icon in "wordicon.exe" is displayed, which is not the document icon.

For AU3 files, the output is C:\...\au3script_v10.ico and the icon shows correctly.

Notice that the system file types return "-000" while MS Office file types return "000".

I've tried adding and subtracting various values, absolute value, negated absolute value, using the negative index number, and using just the index number w/o extra processing, in multiple combinations, with no success.

Below is the code in question.

;initialize rest of GUI
$ICON = GUICtrlCreateIcon(...) ;loads application icon on start
$FILE = FileOpenDialog(...) ;only allows selection of 1 file
;Load other file information
$TEMP = StringSplit(RegRead("HKCR\" & RegRead("HKCR\." & GetFileExt($FILE), "") & "\DefaultIcon", ""), ",")
If $TEMP[0] > 1 Then ; if a multi-icon file is defined, then
    GUICtrlSetImage($ICON, $TEMP[1], -Number($TEMP[$TEMP[0]])) ;use the negated index number.
Else
    GUICtrlSetImage($ICON, $TEMP[1], 0) ;use the first icon
EndIf
;Copies file

Func GetFileExt($PATH) ; Gets the characters after "." in $PATH.
    $TMP = StringSplit($PATH, ".")
    Return $TMP[$TMP[0]]
EndFunc   ;==>GetFileExt

I COULD just use the code as-is, but the rest of the GUI (below) looks great and I don't want to mess up this one part.

Posted Image

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...