01 | const char * ReadResources( char *name) |
02 | { |
03 | lua_State * L = luaL_newstate() ; //创建lua运行环境 |
04 |
05 | int ret = 0 ; |
06 | ret = luaL_loadfile(L, "winlt.lua" ) ; //加载lua脚本文件 |
07 | ret = lua_pcall(L,0,0,0) ; |
08 | lua_getglobal(L, "getResource" ); //函数名 |
09 | lua_pushlstring(L,name, strlen (name)); |
10 | //运行函数并把结果压入栈 |
11 | lua_call(L, 1, 1); |
12 | const char * c=( const char *)lua_tostring(L,-1); |
13 | lua_pop(L, 1); |
14 | lua_close(L) ; //释放lua运行环境 |
15 | return c; |
16 | } |
1 | entity={ |
2 | [ "ResourcePath" ]= "\\skin" , |
3 | [ "ResourceZip" ]= "default.zip" , |
4 | [ "title" ]= "彩票筛选器" , |
5 | [ "xml" ]= "skin_zh.xml" |
6 | }; |
7 | function getResource(name) |
8 | return entity[name]; |
9 | end |
01 | int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/ , LPSTR /*lpCmdLine*/ , int nCmdShow) |
02 | { |
03 | CPaintManagerUI::SetInstance(hInstance); |
04 | //CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath()); |
05 | CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + ReadResources( "ResourcePath" )); |
06 | CPaintManagerUI::SetResourceZip(ReadResources( "ResourceZip" )); |
07 |
08 | HRESULT Hr = ::CoInitialize(NULL); |
09 | if ( FAILED(Hr) ) return 0; |
10 |
11 | CFrameWindowWnd* pFrame = new CFrameWindowWnd(); |
12 | if ( pFrame == NULL ) return 0; |
13 |
14 | pFrame->Create(NULL, ReadResources( "title" ), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); |
15 | pFrame->CenterWindow(); |
16 | ::ShowWindow(*pFrame,SW_SHOW); |
17 | CPaintManagerUI::MessageLoop(); |
18 |
19 | ::CoUninitialize(); |
20 | return 0; |
21 | } |
联系客服