// --------------------------------------------------------------------------- #include #pragma hdrstop #include #include "GlobalUnit.h" #include "tlhelp32.h" USEFORM("Src\MainFormUnit.cpp", MainForm); //--------------------------------------------------------------------------- HWND hWnd = NULL; HINSTANCE u_hMMDll = NULL, u_hCSDll = NULL, u_hCMDll = NULL; int LoadDlls() { u_hMMDll = LoadLibrary(L"MediaModule.dll"); if (u_hMMDll == NULL) { return 1; } else if (GetMMFunctions(u_hMMDll) == S_FALSE) { return 2; } u_hCMDll = LoadLibrary(L"CompModule.dll"); if (u_hCMDll == NULL) { return 7; } else if (GetMSFunctions(u_hCMDll) == S_FALSE) { return 8; } u_hCSDll = LoadLibrary(L"ClientService.dll"); if (u_hCSDll == NULL) { return 5; } else if (GetCSFunctions(u_hCSDll) == S_FALSE) { return 6; } return 0; } void FreeDlls() { if (u_hMMDll) { FreeLibrary(u_hMMDll); u_hMMDll = NULL; } if (u_hCMDll) { FreeLibrary(u_hCMDll); u_hCMDll = NULL; } if (u_hCSDll) { FreeLibrary(u_hCSDll); u_hCSDll = NULL; } } // --------------------------------------------------------------------------- WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { HANDLE hMutex = CreateMutex(NULL, FALSE, L"RunOnlyOneInstance"); if (hMutex == NULL || ERROR_ALREADY_EXISTS == ::GetLastError()) { return 0; } try { Application->Initialize(); Application->Title = APPNAME; Application->MainFormOnTaskBar = true; String strErr; int err; switch (LoadDlls()) { case 1: strErr = "加载媒体控制模块失败!"; break; case 2: strErr = "获取媒体控制函数失败!"; break; case 3: strErr = "加载媒体处理模块失败!"; break; case 4: strErr = "获取媒体处理函数失败!"; break; case 5: strErr = "加载网络服务模块失败!"; break; case 6: strErr = "获取网络服务函数失败!"; break; case 7: strErr = "加载风格制作模块失败!"; break; case 8: strErr = "获取风格制作函数失败!"; break; case 9: strErr = "获取风格批量合成模块失败!"; break; case 10: strErr = "获取风格批量合成函数失败!"; break; default: break; } if (!strErr.IsEmpty()) { AnsiString strErrA = strErr; OutputDebugStringA(strErrA.c_str()); MessageBox(NULL, strErr.c_str(), L"错误提示", MB_OK); FreeDlls(); return 0; } UnicodeString strPath = ExtractFilePath(Application->ExeName); g_strExecutePath = strPath.c_str(); Application->CreateForm(__classid(TMainForm), &MainForm); Application->Run(); FreeDlls(); ReleaseMutex(hMutex); CloseHandle(hMutex); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } return 0; } // ---------------------------------------------------------------------------