使用SHBrowseForFolder为什么“我的电脑”不可选(100分)

  • 主题发起人 主题发起人 lchyy
  • 开始时间 开始时间
L

lchyy

Unregistered / Unconfirmed
GUEST, unregistred user!
以下例子<br>uses ShlObj, ActiveX;<br><br>var<br> &nbsp;FPath:string;<br><br>function BrowseCallBackProc(hwnd: HWND;uMsg: UINT;lParam: Cardinal;lpData: Cardinal): integer; stdcall;<br>begin<br> &nbsp; &nbsp;if uMsg=BFFM_INITIALIZED then<br> &nbsp; &nbsp; &nbsp; &nbsp;result :=SendMessage(Hwnd,BFFM_SETSELECTION,Ord(TRUE),Longint(PChar(FPath)))<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp; &nbsp;result :=1<br>end;<br><br>function BrowseDir(const OwnerHandle:HWND;const Caption: string; const Root:WideString):string ;<br>var<br> &nbsp; &nbsp;BI: BROWSEINFO;<br> &nbsp; &nbsp;IDLt: pointer;<br>begin<br> &nbsp; &nbsp;fillchar(BI,sizeof(BROWSEINFO),0);<br> &nbsp; &nbsp;BI.hWndOwner := OwnerHandle;<br> &nbsp; &nbsp;BI.iImage := 0;<br> &nbsp; &nbsp;BI.lParam := 1;<br> &nbsp; &nbsp;BI.lpfn := nil;<br> &nbsp; &nbsp;BI.lpszTitle := PAnsiChar(Caption);<br> &nbsp; &nbsp;BI.ulFlags := BIF_RETURNONLYFSDIRS;<br> &nbsp; &nbsp;FPath:=Root;<br> &nbsp; &nbsp;BI.lpfn :=@BrowseCallBackProc;<br> &nbsp; &nbsp;BI.lParam :=BFFM_INITIALIZED;<br> &nbsp; &nbsp;IDLt := SHBrowseForFolder(BI);<br> &nbsp; &nbsp;if Assigned(IDLt) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;setlength(Result,MAX_PATH);<br> &nbsp; &nbsp; &nbsp; &nbsp;SHGetPathFromIDList(IDLt, pchar(Result));<br> &nbsp; &nbsp;end;<br>end;<br><br>procedure TFormTest.BitBtn2Click(Sender: TObject);<br>begin<br> &nbsp;BrowseDir(Handle,'aaa','c:/');<br>end;<br><br>=========================================================<br>为什么点击项目“我的电脑”时“确定”的按钮是灰色的
 
后退
顶部