Esempio n. 1
0
HINSTANCE VBA::winLoadLanguage(const char *name)
{
  CString buffer;

  buffer.Format( _T("vba_%s.dll"), name);

#ifdef _AFXDLL
  HINSTANCE l = AfxLoadLibrary( buffer );
#else
  HMODULE l = LoadLibrary( buffer );
#endif

  if(l == NULL) {
    if(strlen(name) == 3) {
      char buffer2[3];
      buffer2[0] = name[0];
      buffer2[1] = name[1];
      buffer2[2] = 0;
      buffer.Format("vba_%s.dll", buffer2);

#ifdef _AFXDLL
	  return AfxLoadLibrary( buffer );
#else
	  return LoadLibrary( buffer );
#endif
    }
  }
  return l;
}
Esempio n. 2
0
    static HMODULE LoadLibraryMB(const char* path)
    {
#ifdef _UNICODE
        int len = _mbslen((const unsigned char*)path);
        int siz = MultiByteToWideChar(0,0, path,len, NULL,0);
        TCHAR* apath = (TCHAR*)HMD_ALLOCA((siz+1) * sizeof(TCHAR));
        MultiByteToWideChar(0,0, path,len, apath,siz);
        return AfxLoadLibrary(apath);
#else
        return AfxLoadLibrary(path);
#endif
    }
Esempio n. 3
0
void CDlg::OnBnClickedButton5()
{
//Товар-склад
	COleVariant vC;
	short i;
	BeginWaitCursor();
		HMODULE hMod;
		BOOL bFndC;
		CString strFndC;
		bFndC   = FALSE;
		strFndC = _T("");
		if(IsEnableRec(ptrRs1)){
			i = 0;
			vC = GetValueRec(ptrRs1,i);
			vC.ChangeType(VT_BSTR);
			strFndC = vC.bstrVal;
			strFndC.TrimLeft();
			strFndC.TrimRight();

			bFndC = TRUE;
		}
		hMod=AfxLoadLibrary(_T("OrdStrg.dll"));
		typedef BOOL (*pDialog)(CString,_ConnectionPtr,CString,BOOL);
		pDialog func=(pDialog)GetProcAddress(hMod,"startOrdStrg");
		(func)(m_strNT, ptrCnn,strFndC,bFndC);

//		m_SlpDay.SetDate(t1);

		AfxFreeLibrary(hMod);
	EndWaitCursor();
}
Esempio n. 4
0
//获取图标
DWORD CServerItemView::GetGameImageIndex(LPCTSTR pszProcess, WORD wKindID)
{
	//寻找现存
	tagGameResourceInfo * pGameResourceInfo=NULL;
	for (INT_PTR i=0;i<m_GameResourceArray.GetCount();i++)
	{
		pGameResourceInfo=&m_GameResourceArray[i];
		if (pGameResourceInfo->wKindID==wKindID) return pGameResourceInfo->dwImageIndex;
	}

	//加载资源
	HINSTANCE hInstance=AfxLoadLibrary(pszProcess);
	if (hInstance==NULL) return IND_KIND_UNKNOW;
	
	//加载标志
	CBitmap GameLogo;
	DWORD dwImagePos=0L;
	AfxSetResourceHandle(hInstance);
	if (GameLogo.LoadBitmap(TEXT("GAME_LOGO"))) dwImagePos=m_ImageList.Add(&GameLogo,RGB(255,0,255));
	AfxSetResourceHandle(GetModuleHandle(NULL));
	AfxFreeLibrary(hInstance);

	//保存信息
	if (dwImagePos!=0L)
	{
		tagGameResourceInfo GameResourceInfo;
		memset(&GameResourceInfo,0,sizeof(GameResourceInfo));
		GameResourceInfo.wKindID=wKindID;
		GameResourceInfo.dwImageIndex=dwImagePos;
		m_GameResourceArray.Add(GameResourceInfo);
		return GameResourceInfo.dwImageIndex;
	}
	
	return IND_KIND_UNKNOW;
}
Esempio n. 5
0
int CallVFSMOD(LPCSTR strVfsProjFile)
{
	int nReturnVal = 0;

	HINSTANCE m_hViewDll;
//	m_hViewDll = AfxLoadLibrary("E:\\CVS\\VFSMOD_DLL\\Debug\\VFSDLL.dll");
	m_hViewDll = AfxLoadLibrary("VFSDLL.dll");	//DLL in sys32 folder
	
	if (!m_hViewDll)
	{
	  AfxMessageBox("Error: Cannot find component \"VFSDLL.dll\"");
	  return nReturnVal;
	}

	GETDLLVIEW GetView = (GETDLLVIEW) GetProcAddress(m_hViewDll, "StartBufferSimulation");
//	ASSERT (GetView != NULL);

   if (!GetView)
   {
      // handle the error
      FreeLibrary(m_hViewDll);
	  AfxMessageBox("Error: Cannot find DLL entry point \"StartBufferSimulation\"");
	  return nReturnVal;
   }
   else
   {
      // call the function
      nReturnVal = GetView(strVfsProjFile, strlen(strVfsProjFile));
      FreeLibrary(m_hViewDll);
   }

	return nReturnVal;
}
Esempio n. 6
0
bool TemplateManager::LoadTplFile(const CString& filename)
{
	// Load the DLL.
	HINSTANCE module = AfxLoadLibrary(filename);
	if (module)
	{
		pfnWWhizTemplateRegister wwhizTemplateRegister =
			(pfnWWhizTemplateRegister)::GetProcAddress(module, "WWhizTemplateRegister");
		if (!wwhizTemplateRegister)
		{
			AfxFreeLibrary(module);
			return false;
		}
		else
		{
			m_loadedCommandModules.Add(module);
#ifdef WWHIZ_VC6
			(*wwhizTemplateRegister)(this, ObjModelHelper::GetInterface());
#endif WWHIZ_VC6
#ifdef WWHIZ_VSNET
			(*wwhizTemplateRegister)(g_wwhizInterface, this, g_pDTE);
#endif WWHIZ_VSNET
			return true;
		}
	}

	return false;
}
Esempio n. 7
0
CHtmlHelp::CHtmlHelp()
{
    m_htmlHelpInstance = AfxLoadLibrary("HHCTRL.OCX");
    if (m_htmlHelpInstance)
#ifndef UNICODE
        m_htmlHelpFunction = (fnHtmlHelp)::GetProcAddress(m_htmlHelpInstance, "HtmlHelpA");
#else
        m_htmlHelpFunction = (fnHtmlHelp)::GetProcAddress(m_htmlHelpInstance, "HtmlHelpW");
#endif //UNICODE
    else
Esempio n. 8
0
void CDlg::ButtonClickDatagrid4(short ColIndex)
{
    COleVariant vC,vBk;
    short i;
    if(IsEnableRec(ptrRs4)) {
        vBk = ptrRs4->GetBookmark();
        switch(ColIndex) {
        case 1:
        {
            BOOL bFndC;
            CString strFndC;
            bFndC   = TRUE;
            strFndC = _T("");
            i=0;
            vC = GetValueRec(ptrRs4,i);
            vC.ChangeType(VT_BSTR);
            strFndC=vC.bstrVal;
            strFndC.TrimLeft();
            strFndC.TrimRight();

            BeginWaitCursor();

            //		m_SlpDay.SetDate(t1);
            HMODULE hMod;
            hMod=AfxLoadLibrary(L"Stg.dll");
            typedef BOOL (*pDialog)(CString,_ConnectionPtr,CString,BOOL);
            pDialog func=(pDialog)GetProcAddress(hMod,"startStg");
            (func)(m_strNT, ptrCnn,strFndC,bFndC);

            //		m_SlpDay.SetDate(t1);

            AfxFreeLibrary(hMod);

            EndWaitCursor();
        }
        break;
        }
        try {
            ptrRs4->Requery(adCmdText);//adCmdStoredProc
            m_DataGrid4.Refresh();
            InitDataGrid4(m_DataGrid4,ptrRs4);
            if(!IsEmptyRec(ptrRs4)) {
                try {
                    ptrRs4->PutBookmark(vBk);
                }
                catch(...) {
                    ptrRs4->MoveLast();
                }
            }
        }
        catch(_com_error& e) {
            AfxMessageBox(e.ErrorMessage());
        }
    }
}
Esempio n. 9
0
void CDlg::OnBnClickedButton1()
{
	BeginWaitCursor();

//		m_SlpDay.SetDate(t1);
		HMODULE hMod;
		BOOL bFndC;
		CString strFndC,strIns;
		COleVariant vC;
		short i;
		bFndC   = TRUE;
		strFndC = _T("");
		if(IsEnableRec(ptrRsCmb1)){
			i = 0;
			vC = GetValueRec(ptrRsCmb1,i);
			vC.ChangeType(VT_BSTR);
			strFndC = vC.bstrVal;
			strFndC.TrimLeft();
			strFndC.TrimRight();
		}
		hMod=AfxLoadLibrary(_T("NameUnit.dll"));
		typedef BOOL (*pDialog)(CString,_ConnectionPtr,CString&,BOOL);
		pDialog func=(pDialog)GetProcAddress(hMod,"startNameUnit");
		(func)(m_strNT, ptrCnn,strFndC,bFndC);
//		m_SlpDay.SetDate(t1);
		AfxFreeLibrary(hMod);
		try{
			ptrRsCmb1->Requery(adCmdText);
			m_DataCombo1.Refresh();
			OnFindInCombo(strFndC,&m_DataCombo1,ptrRsCmb1,0,1);
			i = 1;
			vC = GetValueRec(ptrRsCmb1,i);
			vC.ChangeType(VT_BSTR);
			strIns = vC.bstrVal;
			m_DataCombo1.put_BoundText(strIns);

		}
		catch(_com_error& e){
			AfxMessageBox(e.Description());
		}


	EndWaitCursor();
}
Esempio n. 10
0
void CDlg::OnBnClickedButton1()
{
//Добавить Адрес
	BeginWaitCursor();
		CString strCod,strIns;
		COleVariant vC;
		strCod = _T("0");
		strIns = _T("IT49 ");
		short i=0;
		if(ptrRs1->State==adStateOpen){
			if(!IsEmptyRec(ptrRs1)){
				vC = GetValueRec(ptrRs1,i);
				vC.ChangeType(VT_BSTR);
				strCod=vC.bstrVal;
				strCod.TrimLeft(' ');
				strCod.TrimRight(' ');
		//		m_SlpDay.SetDate(t1);

				HMODULE hMod;
				hMod=AfxLoadLibrary(_T("AddBk.dll"));
				typedef BOOL (*pDialog)( CString, _ConnectionPtr,CString,CString );
				pDialog func=(pDialog)GetProcAddress(hMod,"startAddBk");
				if((func)(m_strNT, ptrCnn,strCod,strIns)){
					if(m_iBtSt==5){
						if(ptrRs2->State==adStateOpen){
//							ptrRs2->Requery(adCmdText);
//								InitDataGrid2(m_DataGrid2,ptrRs2);
//							else{
							OnShowAddres();
						}
					}
				}

		//		m_SlpDay.SetDate(t1);

				AfxFreeLibrary(hMod);
			}
		}

	EndWaitCursor();
}
Esempio n. 11
0
//更新图标
VOID CGameServerDlg::UpdateServerLogo(LPCTSTR pszServerDLL)
{
	//加载资源
	HINSTANCE hInstance=AfxLoadLibrary(pszServerDLL);

	//加载图形
	if (hInstance!=NULL)
	{
		//设置资源
		AfxSetResourceHandle(hInstance);

		//设置资源
		CStatic * pServerLogo=(CStatic *)GetDlgItem(IDC_SERVER_LOGO);
		pServerLogo->SetIcon(::LoadIcon(hInstance,TEXT("SERVER_ICON")));

		//释放资源
		AfxFreeLibrary(hInstance);
		AfxSetResourceHandle(GetModuleHandle(NULL));
	}

	return;
}
Esempio n. 12
0
//加载模块
bool CServiceParameter::LoadGameServiceModule(LPCTSTR pszModuleName)
{
	//效验状态
	ASSERT(m_hDllInstance==NULL);
	ASSERT(m_pIGameServiceManager==NULL);

	//加载模块
	m_hDllInstance=AfxLoadLibrary(pszModuleName);
	if (m_hDllInstance==NULL)
	{
		FreeGameServiceModule();
		return false;
	}

	//查找函数
	ModuleCreateProc * CreateFunc=(ModuleCreateProc *)GetProcAddress(m_hDllInstance,TEXT("CreateGameServiceManager"));
	if (CreateFunc==NULL)
	{
		FreeGameServiceModule();
		return false;
	}

	//获取接口
	m_pIGameServiceManager=(IGameServiceManager *)CreateFunc(IID_IGameServiceManager,VER_IGameServiceManager);
	if (m_pIGameServiceManager==NULL)
	{
		FreeGameServiceModule();
		return false;
	}

	//获取属性
	m_pIGameServiceManager->GetGameServiceAttrib(m_GameServiceAttrib);
	lstrcpyn(m_OptionParameter.szModuleName,m_GameServiceAttrib.szServerModuleName,CountArray(m_OptionParameter.szModuleName));

	return true;
}
Esempio n. 13
0
void CGDSApp::GetALLInterfaces(const CString& pathName, DLLTYPE type)
{//@CODE_3649

	HINSTANCE dllHandle;
	GETDLLVERSION GetDLLVersion;
	GETDLLINTERFACE GetDLLInterface;
	CString Mess;

	DWORD version;
	CDLLInterface *ri;
	

	// try loading the dll here
	dllHandle = AfxLoadLibrary(pathName);
	if (dllHandle == NULL)
	{
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | 
				FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 
				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
				(LPTSTR) &lpMsgBuf, 0, NULL);
		// Display the string.
		Mess.Format(_T("Error Loading DLL:%s\n%s\n"), pathName, lpMsgBuf);
		MessageBox(NULL, Mess, "Error", MB_OK | MB_ICONINFORMATION );
		// Free the buffer.
		LocalFree( lpMsgBuf );
		return;
	}

	// make sure this dll is ok
	GetDLLVersion = (GETDLLVERSION)GetProcAddress(dllHandle, _T("GetDLLVersion"));
	GetDLLInterface = (GETDLLINTERFACE)GetProcAddress(dllHandle, _T("GetDLLInterface"));
	if ((GetDLLVersion == NULL) || (GetDLLInterface == NULL))
	{
		Mess.Format(_T("Unable to load %s\n"
			"Unable to locate either init or version function.\n"), pathName);
		MessageBox(NULL, Mess, _T("DLL Load Error!"), MB_OK | MB_ICONINFORMATION);
		AfxFreeLibrary(dllHandle);
		return;
	}

	version = (*GetDLLVersion)();
	if (version != INTERFACEDLLVERSION)
	{
		Mess.Format(_T("Unable to load %s\n"
			"version %x doesn't match expected %x.\n"), pathName, version, INTERFACEDLLVERSION);
		MessageBox(NULL, Mess, _T("DLL Load Error!"),MB_OK | MB_ICONINFORMATION);
		FreeLibrary(dllHandle);
		return;
	}

	ri = GetDLLInterface(m_ProgramInfo);
	if (ri == NULL)
	{
		Mess.Format(_T("Unable to load %s\n"
			"GetDLLInterface routine failed.\n"), pathName);
		MessageBox(NULL, Mess, _T("DLL Load Error!"), MB_OK | MB_ICONINFORMATION);
		AfxFreeLibrary(dllHandle);
		return;
	}

    if (ri->m_Priority == 0)
    {
        gLogger->Print(_T("Priority should have been set in %s::GetDLLInterface()"),
            pathName);
    }

    ri->m_Type = type;
	m_DLLHandles.push_back(dllHandle);
	m_DLLS.push_back(ri);
}//@CODE_3649
Esempio n. 14
0
int winVideoModeSelect(CWnd *pWnd, GUID **guid)
{
#ifdef _AFXDLL
  HINSTANCE h = AfxLoadLibrary("ddraw.dll");
#else
  HMODULE h = LoadLibrary( _T("ddraw.dll") );
#endif
 
  // If ddraw.dll doesn't exist in the search path,
  // then DirectX probably isn't installed, so fail.
  if (!h)
    return -1;
  
  gDriverCnt = 0;
  
  // Note that you must know which version of the
  // function to retrieve (see the following text).
  // For this example, we use the ANSI version.
  LPDIRECTDRAWENUMERATEEX lpDDEnumEx;
  lpDDEnumEx = (LPDIRECTDRAWENUMERATEEX)
    GetProcAddress(h,"DirectDrawEnumerateExA");
 
  // If the function is there, call it to enumerate all display 
  // devices attached to the desktop, and any non-display DirectDraw
  // devices.
  if (lpDDEnumEx)
    lpDDEnumEx(DDEnumCallbackEx, NULL, 
               DDENUM_ATTACHEDSECONDARYDEVICES |
               DDENUM_NONDISPLAYDEVICES 
               );
  else {
    /*
     * We must be running on an old version of DirectDraw.
     * Therefore MultiMon isn't supported. Fall back on
     * DirectDrawEnumerate to enumerate standard devices on a 
     * single-monitor system.
     */
    BOOL (WINAPI *lpDDEnum)(LPDDENUMCALLBACK, LPVOID);
    
    lpDDEnum = (BOOL (WINAPI *)(LPDDENUMCALLBACK, LPVOID))
      GetProcAddress(h, "DirectDrawEnumerateA");
    if(lpDDEnum)
      lpDDEnum(DDEnumCallback,NULL);
    
    /* Note that it could be handy to let the OldCallback function
     * be a wrapper for a DDEnumCallbackEx. 
     * 
     * Such a function would look like:
     *    BOOL FAR PASCAL OldCallback(GUID FAR *lpGUID,
     *                                LPSTR pDesc,
     *                                LPSTR pName,
     *                                LPVOID pContext)
     *    {
     *         return Callback(lpGUID,pDesc,pName,pContext,NULL);
     *    }
     */
  }

  int selected = 0;

  if(gDriverCnt > 1) {
    VideoDriverSelect d(pWnd);

    INT_PTR selected = d.DoModal();

    if(selected == -1) {
#ifdef _AFXDLL
      AfxFreeLibrary( h );
#else
      FreeLibrary( h );
#endif
      
      return -1;
    }
  }

  HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *);  
  DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *))
    GetProcAddress(h, "DirectDrawCreateEx");

  LPDIRECTDRAW7 ddraw = NULL;
  if(DDrawCreateEx) {
    HRESULT hret = DDrawCreateEx(Drivers[selected].pGUID,
                                 (void **)&ddraw,
                                 IID_IDirectDraw7,
                                 NULL);
    if(hret != DD_OK) {
      systemMessage(0, "Error during DirectDrawCreateEx: %08x", hret);
#ifdef _AFXDLL
      AfxFreeLibrary( h );
#else
      FreeLibrary( h );
#endif
      return -1;
    }
  } else {
    // should not happen....
    systemMessage(0, "Error getting DirectDrawCreateEx");
#ifdef _AFXDLL
    AfxFreeLibrary( h );
#else
    FreeLibrary( h );
#endif
    return -1;
  }  
  
  VideoMode dlg(ddraw, pWnd);

  INT_PTR res = dlg.DoModal();

  if(res != -1) {
    *guid = Drivers[selected].pGUID;
  }
  ddraw->Release();
  ddraw = NULL;

  // If the library was loaded by calling LoadLibrary(),
  // then you must use FreeLibrary() to let go of it.
#ifdef _AFXDLL
  AfxFreeLibrary( h );
#else
  FreeLibrary( h );
#endif

  return (int)res;
}
Esempio n. 15
0
//////////////////////////////////////////////////////////////////////////
//功能:调用视频DLL
//输入:
//返回:
void CGameFrameDlg::SetupVideoDLL()
{
	CString strFile,strTemp;
	CTime tmCur = CTime::GetCurrentTime();
	CString strTime = tmCur.Format("%m%d");
	strFile.Format("log\\%sSetupVideoDLL.log",strTime);

	strTemp.Format("into SetupVideoDLL");
	WriteLog(strFile, strTemp);

	myhinstDLL = AfxLoadLibrary("FlyGameAVClient.dll");

	if (myhinstDLL)
	{}
	else
	{
		AfxMessageBox("视频组件调用失败!");
		isHaveSetupAV = 2;//调用失败
		return ;
	}//End if

	//StopAVClient
	if ( myhinstDLL )
	{
		StopAVClient Proc;
		Proc = (StopAVClient) GetProcAddress( myhinstDLL, "StopAVClient");

		int		iTemp = Proc();
		//	FreeLibrary( hinstDLL );
	}
	else
	{
		//	AfxMessageBox("Not found dll !");
	}//End if	

	if ( myhinstDLL )
	{
		CString avServerIPStr, userIDStr, roomIDStr, tableIDStr, deskIDStr;

		char avServerIP[50];
		char *p;

		WORD wChairID=GetMeChairID();
		const tagUserData * pUserInfo=GetUserData(wChairID);

		if (pUserInfo!=NULL)
		{
			userIDStr.Format("%d", pUserInfo->dwUserID);//
			deskIDStr.Format("%d", wChairID);//椅子位置
			tableIDStr.Format("%d", pUserInfo->wTableID );//桌子号码
		}

		//房间编号
		ASSERT(m_ClientKernelHelper.GetInterface()!=NULL);
		const tagServerAttribute * pServer = m_ClientKernelHelper->GetServerAttribute();
		roomIDStr.Format("%d", pServer->wServerID);

		CString myIPStr ;
		myIPStr = Glb().m_CenterServerIPAddr;
		myIPStr.Replace("http://", "");

		strTemp.Format("myIPStr %s", myIPStr);
		WriteLog(strFile, strTemp);

		avServerIPStr.Format("%s", myIPStr );//采用中心服务器IP

		CString showMsg;
		showMsg.Format("userid=%s, roomid=%s, tableIDStr=%s, deskIDStr=%s,avServerIPStr=%s", userIDStr, roomIDStr,tableIDStr, deskIDStr, avServerIPStr );
		//AfxMessageBox(showMsg);

		strTemp.Format("into SetupVideoDLL %s", showMsg);
		WriteLog(strFile, strTemp);

		p= avServerIPStr.GetBuffer(avServerIPStr.GetLength());
		strcpy( avServerIP, p);

		HWND myhWnd = m_showSelfVideo.m_hWnd;

		StartAVClient Proc;
		Proc = (StartAVClient) GetProcAddress( myhinstDLL, "StartAVClient");

		int		iTemp = Proc(myhWnd /*myCwnd this*/, 
			avServerIP,
			UDP_SOCKET_REG_PORT     , 
			atoi(userIDStr),
			atoi(roomIDStr), 
			atoi(tableIDStr),
			atoi(deskIDStr)
			);
		//	FreeLibrary( hinstDLL );
	}
	else
	{
		//AfxMessageBox("Not found dll !");
	}//End if	

	HWND hRemoteWnd[REMOTE_VIDEO_MAX_NUM];
	hRemoteWnd[0] = 	m_showRemoteVideo.m_hWnd;
	hRemoteWnd[1] = 	m_showRemoteVideo1.m_hWnd;
	hRemoteWnd[2] = 	m_showRemoteVideo2.m_hWnd;
	hRemoteWnd[3] = 	m_showRemoteVideo3.m_hWnd;

	for (int i=0; i <REMOTE_VIDEO_MAX_NUM ; i++)
	{
		SetOneRemoteShowHWND( hRemoteWnd[i], i);
	}
	/*
	if ( myhinstDLL )
	{
	AVClientSendRegMsg Proc;
	Proc = (AVClientSendRegMsg) GetProcAddress( myhinstDLL, "AVClientSendRegMsg");

	int		iTemp = Proc();
	//	FreeLibrary( hinstDLL );
	}
	else
	{
	AfxMessageBox("Not found dll !");

	}	

	if ( myhinstDLL )
	{
	GetOneTablePlayerList Proc;
	Proc = (GetOneTablePlayerList) GetProcAddress( myhinstDLL, "GetOneTablePlayerList");

	int		iTemp = Proc();
	//	FreeLibrary( hinstDLL );
	}
	else
	{
	AfxMessageBox("Not found dll !");
	}	
	*/
	FlyAVClientSendRegMsg();
	FlyGetOneTablePlayerList();

	isHaveSetupAV = 1;//调用成功
}
Esempio n. 16
0
bool DirectDrawDisplay::initialize()
{
  theApp.sizeX = 240;
  theApp.sizeY = 160;

  switch(theApp.videoOption) {
  case VIDEO_1X:
    theApp.surfaceSizeX = theApp.sizeX;
    theApp.surfaceSizeY = theApp.sizeY;
    break;
  case VIDEO_2X:
    theApp.surfaceSizeX = theApp.sizeX * 2;
    theApp.surfaceSizeY = theApp.sizeY * 2;
    break;
  case VIDEO_3X:
    theApp.surfaceSizeX = theApp.sizeX * 3;
    theApp.surfaceSizeY = theApp.sizeY * 3;
    break;
  case VIDEO_4X:
    theApp.surfaceSizeX = theApp.sizeX * 4;
    theApp.surfaceSizeY = theApp.sizeY * 4;
    break;
  case VIDEO_320x240:
  case VIDEO_640x480:
  case VIDEO_800x600:
  case VIDEO_OTHER:
    {
      int scaleX = (theApp.fsWidth / theApp.sizeX);
      int scaleY = (theApp.fsHeight / theApp.sizeY);
      int min = scaleX < scaleY ? scaleX : scaleY;
      if(theApp.fsMaxScale)
        min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min;
      theApp.surfaceSizeX = theApp.sizeX * min;
      theApp.surfaceSizeY = theApp.sizeY * min;
      if(theApp.fullScreenStretch) {
        theApp.surfaceSizeX = theApp.fsWidth;
        theApp.surfaceSizeY = theApp.fsHeight;
      }
    }
    break;
  }
  
  theApp.rect.left = 0;
  theApp.rect.top = 0;
  theApp.rect.right = theApp.sizeX;
  theApp.rect.bottom = theApp.sizeY;

  theApp.dest.left = 0;
  theApp.dest.top = 0;
  theApp.dest.right = theApp.surfaceSizeX;
  theApp.dest.bottom = theApp.surfaceSizeY;

  DWORD style = WS_POPUP | WS_VISIBLE;
  DWORD styleEx = 0;
  
  if(theApp.videoOption <= VIDEO_4X)
    style |= WS_OVERLAPPEDWINDOW;
  else
    styleEx = WS_EX_TOPMOST;

  if(theApp.videoOption <= VIDEO_4X)
    AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx);
  else
    AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx);    

  int winSizeX = theApp.dest.right-theApp.dest.left;
  int winSizeY = theApp.dest.bottom-theApp.dest.top;

  int x = 0;
  int y = 0;

  if(theApp.videoOption <= VIDEO_4X) {
    x = theApp.windowPositionX;
    y = theApp.windowPositionY;
  }

  // Create a window
  MainWnd *pWnd = new MainWnd;
  theApp.m_pMainWnd = pWnd;

  pWnd->CreateEx(styleEx,
                 theApp.wndClass,
                 "VisualBoyAdvance",
                 style,
                 x,y,winSizeX,winSizeY,
                 NULL,
                 0);
  
  if (!(HWND)*pWnd) {
    winlog("Error creating Window %08x\n", GetLastError());
    return FALSE;
  }

  
  theApp.updateMenuBar();
  
  theApp.adjustDestRect();
  
  GUID *guid = NULL;
  if(theApp.ddrawEmulationOnly)
    guid = (GUID *)DDCREATE_EMULATIONONLY;

  if(theApp.pVideoDriverGUID)
    guid = theApp.pVideoDriverGUID;

  ddrawDLL = AfxLoadLibrary("DDRAW.DLL");
  HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *);  
  if(ddrawDLL != NULL) {    
    DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *))
      GetProcAddress(ddrawDLL, "DirectDrawCreateEx");

    if(DDrawCreateEx == NULL) {
      theApp.directXMessage("DirectDrawCreateEx");
      return FALSE;
    }
  } else {
    theApp.directXMessage("DDRAW.DLL");
    return FALSE;
  }

  theApp.ddrawUsingEmulationOnly = theApp.ddrawEmulationOnly;
  
  HRESULT hret = DDrawCreateEx(guid,
                               (void **)&pDirectDraw,
                               IID_IDirectDraw7,
                               NULL);
    
  if(hret != DD_OK) {
    winlog("Error creating DirectDraw object %08x\n", hret);
    if(theApp.ddrawEmulationOnly) {
      // disable emulation only setting in case of failure
      regSetDwordValue("ddrawEmulationOnly", 0);
    }
    //    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWCREATE), hret);
    return FALSE;
  }

  if(theApp.ddrawDebug) {
    DDCAPS driver;
    DDCAPS hel;
    ZeroMemory(&driver, sizeof(driver));
    ZeroMemory(&hel, sizeof(hel));
    driver.dwSize = sizeof(driver);
    hel.dwSize = sizeof(hel);
    pDirectDraw->GetCaps(&driver, &hel);
    int i;
    DWORD *p = (DWORD *)&driver;
    for(i = 0; i < (int)driver.dwSize; i+=4)
      winlog("Driver CAPS %2d: %08x\n", i>>2, *p++);
    p = (DWORD *)&hel;
    for(i = 0; i < (int)hel.dwSize; i+=4)
      winlog("HEL CAPS %2d: %08x\n", i>>2, *p++);
  }
Esempio n. 17
0
//启动游戏房间
bool CServiceManage::bGetServiceInfo(SC_GameRoomInitStruct * pComRoomInfo)
{
	////注册码检测////
	//bool bCheck = false;
	//bCheck = CheckLicense();
	//if(!bCheck)
	//{
	//	return false;
	//}

	//AfxMessageBox("GetServiceInfo!");

	try
	{
		if ((pComRoomInfo->hDllInstance!=NULL)||(pComRoomInfo->pIManageService!=NULL)) return true;

		#ifdef BZ_LICENSE
			if(coreGetGameLicense(pComRoomInfo->ServiceInfo.uNameID)!=pComRoomInfo->ServiceInfo.uNameID)
		#else
			if (false)
		#endif // BZ_LICENSE
		{
			CString s=pComRoomInfo->ServiceInfo.szGameName;
			if(s.Left(7)!="未认证_")
			{
				s="未认证_"+s;
				if(s.GetLength()>60)
					s=s.Left(60);
			}	
			strcpy(pComRoomInfo->ServiceInfo.szGameName,s);		
			return false;
		}
		//判断文件
		struct stat FileStat;
		if (stat(pComRoomInfo->ServiceInfo.szDLLFileName,&FileStat)!=0) 
			return false;
			//throw TEXT("组件不存在");

		//加载组件
		pComRoomInfo->hDllInstance=AfxLoadLibrary(pComRoomInfo->ServiceInfo.szDLLFileName);
		if (pComRoomInfo->hDllInstance==NULL) 
			return false;//throw TEXT("组件装载失败");

		//获取管理接口
		CreateServiceInterface * pCreateServiceInterface=(CreateServiceInterface *)GetProcAddress(pComRoomInfo->hDllInstance,TEXT("CreateServiceInterface"));
		if (pCreateServiceInterface==NULL) 
			return false;//throw TEXT("非法组件");
		pComRoomInfo->pIManageService=pCreateServiceInterface(DEV_LIB_VER);
		if (pComRoomInfo->pIManageService==NULL)
			return false;//throw TEXT("组件管理接口获取失败,可能是资源不足");


		GetServiceInfo * pGetServiceInfo=(GetServiceInfo *)GetProcAddress(pComRoomInfo->hDllInstance,TEXT("GetServiceInfo"));
		if (pGetServiceInfo==NULL) 
			return false;//throw TEXT("非法组件");

        // PengJiLin, 2011-4-2, 指定哪些游戏是可用的
        ServerDllInfoStruct ServiceDllInfo;
        if(FALSE == pGetServiceInfo(&ServiceDllInfo,DEV_LIB_VER)) return false;
        if(FALSE == m_GameSelecter.GameIsUsable(ServiceDllInfo.uNameID)) return false;

		//效验组件
		///ServerDllInfoStruct ServiceDllInfo;
		//ServerDllInfoStruct * temp;
		//if (pGetServiceInfo(temp,DEV_LIB_VER)==FALSE) throw TEXT("获取组件信息失败");


	}
	catch (...)
	{
		TRACE("CATCH:%s with %s\n",__FILE__,__FUNCTION__);
		return false;
	}

	return true;
}