2014-03-04 83 views
1

我需要打開"OpenWith"對話框,其中用戶可以選擇將打開某個文件的程序,例如.xml
在Vista和刨絲器可以通過SHOpenWithDialog完成,但我也需要支持Windows XP。適用於Windows XP的SHOpenWithDialog模擬器?

+1

可能重複的[如何顯示「打開」文件對話框?](http://stackoverflow.com/questions/4726441/how-can-i-show-the-open-with-文件對話框) –

回答

0
bool BrowseOpenWith(const HWND hwnd, LPCTSTR lpszFilename) 
{ 
ASSERT(!IsBadStringPtr(lpszFilename,INFINITE)); 
ASSERT(_tcslen(lpszFilename)); 

if (hwnd) { 
    ASSERT(IsWindow(hwnd)); 
} 

const CString strCmd= 
    TEXT("shell32.dll,OpenAs_RunDLL ") 
    +CString(lpszFilename); 

const int nRet 
    =(int)ShellExecute(hwnd,TEXT("open") 
    ,TEXT("Rundll32.exe") 
    ,strCmd 
    ,NULL 
    ,SW_SHOW); 

return (nRet>32); 
}