News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SHGetFileInfo help

Started by maruf10, February 23, 2010, 06:46:00 PM

Previous topic - Next topic

BlackVortex

CmpIcon is inside the source file posted. It's a procedure.

maruf10

yeah ...
thank u ....
this is really complicated ...
I will try to understand it :)

maruf10

i just want to implement http://msdn.microsoft.com/en-us/library/bb759792(VS.85).aspx
why the output for iIcon of same file is different for different drive/folder??
according to this link it should work  ::)

maruf10

would you please explain the CmpIcon function ?? :red

qWord

The function accepts to icon-handles. GetIconInfo() is used to receive bitmaps form these handles. The next step is do get the dimensions of the bitmaps using GetObject(). Here comes the first compare: if the size is not equal the function returns 0, other wise GetDIBits() is used to obtain the pixels as DWORD-array. This two arrays are simply compared using repe cmpsd.

BTW: I've got the feeling that you mean thumbnails when talking about icons.(?)
FPU in a trice: SmplMath
It's that simple!

maruf10

#35
what is the usage of these lines !!

Quote

LOCAL hdc:HDC
mov hdc,rv(CreateCompatibleDC,rv(GetDC,0))
mov bi.bmiHeader.biSize,SIZEOF BITMAPINFO
   


this is an offtopic

i am using this line

Quote
Command db 'cmd /c dir "H:\file\*.exe"  /s/w/b/a-d >'
WriteFileName db "C:\myFile.txt",0

invoke wshell , addr Command

to list all .exe file of H:\file path in C:\myFile.txt. i want to  take the path as input . if i store the path in Buffer ..how can i execute that Command using Buffer ??

qWord

Quote from: maruf10 on March 22, 2010, 07:45:32 PM
what is the usage of these lines !!

Quote
LOCAL hdc:HDC
mov hdc,rv(CreateCompatibleDC,rv(GetDC,0))
GetDIBits required an hDC to get the  bits. This DC is compatible to the desktop-window ones (GetDC(0)= desktop-DC).
Quote from: maruf10 on March 22, 2010, 07:45:32 PM
mov bi.bmiHeader.biSize,SIZEOF BITMAPINFO
Quote
The first member of  BITMAPINFO-struct must filled with the size of this struct - windows use this to determinate the 'version' of used struct.

Quote from: maruf10 on March 22, 2010, 07:45:32 PMi want to take take the path as input . if i store the path in Buffer ..how can i execute that Command using Buffer ??
look at the szMultiCat-function coming with masmlib. For a description see \masm32\help\masmlib.chm.



FPU in a trice: SmplMath
It's that simple!

maruf10

Quote

Extension db "*.exe",0
Constraint db " /s/w/b/a-d >'",0
pBuf dd ?
StrBuffer dd 256 dup(?)

mov pBuf,offset StrBuffer
print rv(szMultiCat,4,pBuf, chr$("'cmd /c dir "), edi,addr Extension , addr Constraint)
   

how can i print a double quote(") after dir and after Extension??
i have used escape character (!) and (\) .
but its not working .. :(

current output : 'cmd /c dir K:\*.exe /s/w/b/a-d >'

link : http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Appendix_A.htm

qWord

e.g.: chr$(34,"text",34) -> "text"
alternatively use the cfm$()-macro: cfm$("\qtext\q") -> "text"
FPU in a trice: SmplMath
It's that simple!

elmo

I want to get a file icon from it's handle value and show it result to listview with the following code
but it's fail


mov lvi.imask, LVIF_TEXT or LVIF_IMAGE or LVIF_ICON
mov lvi.iSubItem,0
invoke FindWindow,ADDR szWndClass,ADDR szWndText ;WILL RETURN WINHANDLE
invoke SHGetFileInfo,
eax,                      ;I THINK THE WRONG HERE
NULL,
addr sfi, sizeof sfi,
SHGFI_ICON or SHGFI_ICONLOCATION or SHGFI_USEFILEATTRIBUTES
invoke ImageList_AddIcon, hImageListS, sfi.hIcon
mov lvi.iImage, eax
lea eax,szWndHandle
mov lvi.pszText,eax
invoke SendMessage, hList2, LVM_SETITEM, NULL,addr lvi
invoke DestroyIcon, sfi.hIcon

I think the error avail when I call SHGetFileInfo.
I now I must change eax with the full path of the file who I want to view it's icon.
But what I want is: I want to get it's icon from it's handle and then show it result on listview.
How?
would you like to give me a clue?
Sorry for my bad english
thank you
be the king of accounting programmer world!

qWord

You want to get the file icon of an executable  through an window handle?:

1. Get the window handle
2. get the process id using GetWindowThreadProcessId()
3. Open the process with the PROCESS_QUERY_INFORMATION-right
4. use GetModuleFileNameEx() to get the executable path
5. pass the path to SHGetFileInfo
(6. do not forget to close all handles)
FPU in a trice: SmplMath
It's that simple!

dedndave

to help troubleshoot, examine the return values for each INVOKE
in many cases, you have to call GetLastError to find the error code
make a routine that displays error messages in a message box and call it whenever that's the case

if the error is returned in EAX, use CALL RegErr
if not, use CALL LastErr
        .DATA

ErrStr  db 'Error',0

        .CODE

LastErr PROC

        INVOKE  GetLastError

RegErr::
        push    edi
        xor     ecx,ecx
        sub     esp,508
        push    ecx
        mov     edi,esp
        INVOKE  FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,ecx,eax,ecx,edi,512,ecx
        INVOKE  MessageBox,NULL,edi,offset ErrStr,MB_ICONERROR
        add     esp,512
        pop     edi
        ret

LastErr ENDP


it may require a little modification to report winsock errors

dedndave

this one displays the address of the call in the title bar   :P
ErrStr  db 'Error at Address xxxxxxxx',0

        .CODE

LastErr PROC

        INVOKE  GetLastError

RegErr::
        push    esi
        push    edi
        mov     edx,[esp+8]        ;RET address
        sub     edx,5              ;subtract CALL length
        push    eax
        mov     esi,uhex$(edx)
        pop     eax
        mov     edi,offset ErrStr+17
        movsd
        movsd
        xor     ecx,ecx
        sub     esp,508
        push    ecx
        mov     edi,esp
        INVOKE  FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,ecx,eax,ecx,edi,512,ecx
        INVOKE  MessageBox,NULL,edi,offset ErrStr,MB_ICONERROR
        add     esp,512
        pop     edi
        pop     esi
        ret

LastErr ENDP


called with EAX = 122


and, in the code above, i even give you the extra "d" for "address"
....no additional charge

elmo

thank's qWord :U
it work. What a long ways!

btw, in PHP, I can split FileName into an array.
Example:

$filename  = "file1.asm";
$arr = explode(".", $filename);
echo $arr[0]; // WILL RETURN file1
echo $arr[1]; // WILL RETURN asm

How to do it with masm? what API?
would you like to give me a clue?
thank you
sorry for my bad english
be the king of accounting programmer world!

elmo

I got it work! :dance:

but I have problem. now
how can we get file icon/ file attribut/ file type/ file time on WEB?
maybe my correct question is:
  how use API SHGetFileInfo to get information of file(File icon/ file attribut/ file type/ file time) on NET?

I have try to run the following code but the result like the picture in my attached file.
could somebody give a clue?
thanks




                .data?
                hFind dd?
                .
                .
                .
                LOCAL FindData:WIN32_FIND_DATA
LOCAL hConnect:DWORD


INVOKE FtpFindFirstFile,hConnect,SADD("public_html/*.*"),addr FindData,0,0
.if eax != INVALID_HANDLE_VALUE
mov hFind, eax
xor edi, edi
mov edi,0
.while eax != 0
;.if (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
;.if (FindData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
;.if (FindData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
;.if (FindData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)


;ID ROW
mov lvi.imask,LVIF_PARAM
push edi
pop lvi.iItem
mov lvi.iSubItem,0
push edi
pop lvi.lParam
invoke SendMessage,hList1,LVM_INSERTITEM,0,addr lvi


;FILE ICON+FILE NAME
mov lvi.imask,LVIF_TEXT or LVIF_IMAGE
mov lvi.iSubItem,0
INVOKE lstrcpy, addr szPath,SADD("public_html")
invoke lstrcat,addr szPath,addr FindData.cFileName
invoke SHGetFileInfo,
ADDR szPath,
0,
ADDR sfi,SIZEOF sfi,
SHGFI_ICON or SHGFI_LARGEICON or SHGFI_DISPLAYNAME
lea eax,FindData.cFileName          ;TRY TO GET FILENAME (SUCCESS)
mov lvi.pszText,eax
mov eax,sfi.iIcon                        ;TRY TO SHOW ICON BUT STILL FAIL
mov lvi.iImage,eax
invoke SendMessage,hList1,LVM_SETITEM,0,addr lvi


;FILE ATTRIBUT
mov lvi.imask,LVIF_TEXT
inc lvi.iSubItem
INVOKE lstrcpy, addr szPath,SADD("public_html")
invoke lstrcat,addr szPath,addr FindData.cFileName
invoke SHGetFileInfo,
ADDR szPath,
NULL,
addr sfi, sizeof sfi,
SHGFI_ICON or SHGFI_LARGEICON or SHGFI_ICONLOCATION or SHGFI_TYPENAME or SHGFI_ATTRIBUTES
lea eax,sfi.dwAttributes            ;TRY TO GET FILE ATTRIBUT HERE (BUT FAIL)
;lea eax,sfi.szTypeName            ;IF WANT TO GET FILE TYPE(FAIL)
mov lvi.pszText,eax
invoke SendMessage,hList1,LVM_SETITEM,0,addr lvi

inc edi
endsw$
;LOOPING
invoke InternetFindNextFile,hFind,addr FindData
.endw
invoke FindClose,hFind
.else
invoke GetLastError
mov nLastError,eax
invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,NULL, nLastError, NULL, ADDR szMsgBuff, 128, NULL
invoke MessageBoxEx, NULL, ADDR szMsgBuff, SADD("File Handle invalid"),MB_OK+MB_ICONINFORMATION, LANG_ENGLISH
.endif
                mov edi,0

be the king of accounting programmer world!