오피스 파일 구별하기 DarkKaiser, 2007년 7월 17일2023년 9월 4일 /* Word Document (*.doc) : {00020906-0000-0000-C000-000000000046} */ static const GUID CLSID_WORD = { 0x00020906, 0x0, 0x0, { 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46 }}; /* Excel Worksheet (*.xls) : {00020820-0000-0000-C000-000000000046} */ static const GUID CLSID_EXCEL = { 0x00020820, 0x0, 0x0, { 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46 }}; /* PPT Presentation (*.ppt) : {64818D10-4F9B-11CF-86EA-00AA00B929E8} */ static const GUID CLSID_PPT = { 0x64818D10, 0x4F9B, 0x11CF, { 0x86, 0xEA, 0x0, 0xAA, 0x0, 0xB9, 0x29, 0xE8 }}; void IDFileType(BSTR bstrFile) { HRESULT hr = S_OK; IStorage* pStg = NULL; STATSTG ST; char* pszApp; if(NULL == bstrFile) return; /* Open Compound Document for READ Access... */ hr = StgOpenStorage(bstrFile, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &pStg); if(FAILED(hr)) { MessageBox(NULL, "Not a valid Compound Document!", "Error", MB_SETFOREGROUND); return; } ZeroMemory(&ST, sizeof(STATSTG)); /* Get Storage Stats and check CLSID against known values... */ hr = pStg->Stat(&ST, STATFLAG_NONAME); if(SUCCEEDED(hr)) { if (ST.clsid == CLSID_WORD) pszApp = "Word Application"; else if (ST.clsid == CLSID_EXCEL) pszApp = "Excel Application"; else if (ST.clsid == CLSID_PPT) pszApp = "PowerPoint Application"; else pszApp = "Unknown Application"; SetWindowText(GetDlgItem(g_hWnd, IDC_APPNAME), pszApp); } /* Must release IStorage interface to free document!! */ pStg->Release(); C/C++/VC++ 오피스파일구별VC