Duilib程式中出現pRoot為NULL,呼叫xml失敗
阿新 • • 發佈:2018-12-30
在Duilib的專案中,有以下的程式碼:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
atexit(CheckOnExit);
::CoInitialize(NULL);
CPaintManagerUI::SetInstance(hInstance);
CDuiString str = CPaintManagerUI::GetInstancePath();
CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin "));
CDuiFrameWnd *pFrame = new CDuiFrameWnd(_T("XMP.xml"));
pFrame->Create(NULL, _T("迅雷看看播放器"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES);
pFrame->ShowModal();
delete pFrame;
::CoUninitialize();
return 0;
}
出現了以下錯誤:
可以除錯程式碼發現是因為xml檔案沒有載入成功,可以打斷點發現str的值加上"skin"所在的目錄沒有xml檔案,
xml檔案具體在哪個資料夾可以根據具體情況進行調整,當把程式碼調整為如下程式碼是,可以正常執行:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
atexit(CheckOnExit);
::CoInitialize(NULL);
CPaintManagerUI::SetInstance(hInstance);
CDuiString str = CPaintManagerUI::GetInstancePath();
CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("..\\..\\_bin\\skin "));
CDuiFrameWnd *pFrame = new CDuiFrameWnd(_T("XMP.xml"));
pFrame->Create(NULL, _T("迅雷看看播放器"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES);
pFrame->ShowModal();
delete pFrame;
::CoUninitialize();
return 0;
}