-
Notifications
You must be signed in to change notification settings - Fork 5
/
_BrowseFolder.asm
65 lines (59 loc) · 1.54 KB
/
_BrowseFolder.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
.data?
_BrowseFolderTmp dd ?
.const
; _szDirInfo db 'ÇëÑ¡ÔñĿ¼£º',0
TW0 'Please Select Directory:', _szDirInfo
.code
_BrowseFolderCallBack proc hwnd,uMsg,lParam,lpData
local @szBuffer[MAX_STRINGLEN]:byte
mov eax,uMsg
.if eax==BFFM_INITIALIZED
invoke SendMessageW,hwnd,BFFM_SETSELECTIONW,TRUE,_BrowseFolderTmp
.elseif eax==BFFM_SELCHANGED
invoke SHGetPathFromIDListW,lParam,addr @szBuffer
invoke SendMessageW,hwnd,BFFM_SETSTATUSTEXTW,0,addr @szBuffer
.endif
xor eax,eax
ret
_BrowseFolderCallBack endp
;
_BrowseFolder proc _hwnd,_lpszBuffer
local @stBrowseInfo:BROWSEINFO
local @stMalloc
local @pidlParent,@dwReturn
pushad
invoke CoInitialize,NULL
invoke SHGetMalloc,addr @stMalloc
.if eax==E_FAIL
mov @dwReturn,FALSE
jmp @F
.endif
invoke RtlZeroMemory,addr @stBrowseInfo,sizeof @stBrowseInfo
push _hwnd
pop @stBrowseInfo.hwndOwner
push _lpszBuffer
pop _BrowseFolderTmp
mov @stBrowseInfo.lpfn,offset _BrowseFolderCallBack
mov @stBrowseInfo.lpszTitle,offset _szDirInfo
mov @stBrowseInfo.ulFlags,BIF_RETURNONLYFSDIRS OR BIF_STATUSTEXT
invoke SHBrowseForFolderW,addr @stBrowseInfo
mov @pidlParent,eax
.if eax!=NULL
invoke SHGetPathFromIDListW,eax,_lpszBuffer
mov eax,TRUE
.else
mov eax,FALSE
.endif
mov @dwReturn,eax
mov eax,@stMalloc
mov eax,[eax]
invoke (IMalloc ptr [eax]).Free,@stMalloc,@pidlParent
mov eax,@stMalloc
mov eax,[eax]
invoke (IMalloc ptr [eax]).Release,@stMalloc
@@:
invoke CoUninitialize
popad
mov eax,@dwReturn
ret
_BrowseFolder endp