使用GetOpenFileName開啟多個檔案

來源:互聯網
上載者:User
void GetOpenFileName_sample()
{
TCHAR str[320000] = {0};
TCHAR szFile[MAX_PATH+1024];
TCHAR *p = NULL;
TCHAR Name[MAX_PATH];
TCHAR szTmp[MAX_PATH];
int i=1;
memset(szFile,0, sizeof(szFile));
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = _T("*.*/0*.*/0");
ofn.nMaxFile = sizeof(szFile)/sizeof(szFile[0]);
ofn.lpstrFile = szFile;
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST
| OFN_ALLOWMULTISELECT | OFN_EXPLORER;
if (GetOpenFileName(&ofn))
{
p=szFile;
}

TCHAR dir_buf[MAX_PATH+1024];
if(p && p[0])
{
_tcscpy(dir_buf,p);
p = p + _tcslen(dir_buf)+1;
if(!p[0])
{
_tprintf(_T("only 1 file is selected:%s/n"),dir_buf);
}
else
_tcscat(dir_buf,_T("//"));
}
while(p && p[0])
{
_tcscpy(Name, p);
_tcscat(str,dir_buf);
_tcscat(str,Name);
_tcscat(str,_T("/n"));
p = p + _tcslen(Name)+1;
}
_tprintf(_T("%s"),str);
}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.