2013-12-19 14 views
0

單擊mfc代碼中的關係文件時如何獲取文件名?如何在mfc代碼中單擊關係文件時獲取文件名?

現在,我創建的文件相對於文件和執行應用,

當我點擊的關係文件將打開應用程序,但我不能獲取文件名。

我用什麼方法可以得到的文件名,其功能得到哪些變量文件名

再如,使用OndropFile,DragQueryFile將得到 文件名保存在strFilePath變量,如下代碼;

但我需要單擊文件的方法,而不是dropfile。

我的申請是MDI。

void CTerchy_CurveViewView::OnDropFiles(HDROP hDropInfo) 
{ 
CString strPath; 
WCHAR strFilePath[MAX_PATH]; 
::DragQueryFile(hDropInfo, 0, strFilePath, sizeof(strFilePath)); 

strPath = strFilePath; 
if(strPath.Right(4) == _T(".GRP") || strPath.Right(4) == _T(".grp") || 
    strPath.Right(5) == _T(".7215") || strPath.Right(5) == _T(".8103")) 
{ 

文件關聯設置:

Command: Executing application 
Description: None 
Extensions:GRP 
MIME:"%1" 

我找到一個網站,其中談到了文件關係:File Associations In Visual Studio

的 「參數」 默認爲 「%1」,這意味着將完整路徑 和文件名傳遞給您的應用程序。

我該如何獲取文件名?

回答

0

確定可用的,謝謝大家,獲取文件名的方法,應用程序已經impletement, 打開MyAppView.cpp

// 剖析標準 Shell 命令、DDE、檔案開啟舊檔的命令列 
CCommandLineInfo cmdInfo; 
ParseCommandLine(cmdInfo); 

/* 檔案關聯開啟的檔名 */ 
strRelationFile = cmdInfo.m_strFileName; 

我明白了。

0

對於SDI,您可以在命令行上獲取文件名。在標準應用程序中,您可以使用CCommandLine。文件名存儲在那裏。

對於MDI應用程序,使用DDE接口,內部框架工作通過DDE打開文件。 OpenDocument的

相關問題