DllManager.cpp
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:4k
- // mydebug.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "windows.h"
- #include "stdio.h"
- #include "DllManager.h"
- DllManager:: DllManager()
- {
- hWinyDLL=NULL;
- hkeyDLL=NULL;
- hmainWin=0;
- svhWndParent=0;
- SendCH[0]=0;
- Control[0]=0;
- loaderr=0;
- }
- DllManager:: ~DllManager()
- {
- if(NULL!=hWinyDLL)
- {
- if(hmainWin!=0)
- CloseWin(&hmainWin);
- hmainWin=0;
- if(hkeyDLL==hWinyDLL)
- FreeLibrary(hWinyDLL);
- else
- {
- FreeLibrary(hkeyDLL);//卸载TranChiDll.dll文件;
- FreeLibrary(hWinyDLL);
- }
- hWinyDLL=NULL;
- hkeyDLL=NULL;
- //MessageBox (0,"FreeLibrary",0,0);
- }
- }
- DllManager::mgDllEnd()
- {
- if(NULL!=hWinyDLL)
- {
- if(hmainWin!=0)
- CloseWin(&hmainWin);
- hmainWin=0;
- //MessageBox (0,"FreeLibrary",0,0);
- }
- }
-
- int DllManager::mgDllStart()
- {
- int ret=0;
- WIN32_FIND_DATAA tt;
- char ss[260];
- HANDLE fd1,fd2;
- ss[0]=0;
- // MessageBox (0,"Load TranChiDll.dll",0,0);
- SoftkbdParentWnd=NULL;
- fd1=FindFirstFile("c:\jsime\TranChiDll.dll",&tt);
- fd2=FindFirstFile("c:\jsime\jsIMEWin.dll",&tt);
- if(loaderr==1)
- return ret;
- if(fd1==INVALID_HANDLE_VALUE)
- {
- //MessageBox(0,"文件TranChiDll.dll未找到!n 请立即保存,系统可能崩溃!?","IME c:\jsime\",0);
- loaderr=1;
- ret=1;
- }
- else
- {
- ///////////////////////////////////////////////////////////
- if(fd2!=INVALID_HANDLE_VALUE)
- {
- hWinyDLL=LoadLibrary("c:\jsime\jsIMEWin.dll");
- hkeyDLL=hWinyDLL;//通过jsIMEWin调用转换模块
- myCreate=(pmyCreate)GetProcAddress(hWinyDLL,"myCreate");
- CloseWin=(pCloseWin)GetProcAddress(hWinyDLL,"CloseWin");
- SetWinPosition=(pSetWinPosition)GetProcAddress(hWinyDLL,"SetWinPosition");
- SetShowString=(pSetShowString)GetProcAddress(hWinyDLL,"SetShowString");
- UpdateWinShow=(pUpdateWinShow)GetProcAddress(hWinyDLL,"UpdateWinShow");
- HideWin=(pHideWin)GetProcAddress(hWinyDLL,"HideWin");
- HideAllWin=(pHideAllWin)GetProcAddress(hWinyDLL,"HideAllWin");
- //MessageBox (0,"Load jsIMEWin.dll End .",0,0);
- }
- if(hkeyDLL==NULL) //如果jsIMEWin没有加载则直接加载转换模块
- {
- hkeyDLL=LoadLibrary("c:\jsime\TranChiDll.dll");//加载动态链接库.dll文件;
- //MessageBox (0,"窗口模块jsIMEWin没有加载成功","输入将没有提示窗口",0);
- }
- m_myImeProcessKey=(pmyImeProcessKey)GetProcAddress(hkeyDLL,"myImeProcessKey");
- if(myImeProcessKey==NULL)
- MessageBox (0,"入将没有提示窗口",0,0);
- }
- //MessageBox (0,"Load TranChiDll.dll",0,0);
- return ret;
- }
- BOOL DllManager::myImeProcessKey(long *fcmywnd,char *SendCH,char *Control,HIMC hIMC,UINT vKey,LPARAM lKeyData,CONST LPBYTE lpbKeyState)
- {
- BOOL ret=0;
- if(NULL==hkeyDLL){
- loaderr=0;
- mgDllStart();
- if(NULL==hkeyDLL)
- MessageBox (0,"Load TranChiDll.dll 装载失败",0,0);
- }else
- ret=m_myImeProcessKey(fcmywnd,SendCH,Control,hIMC,vKey,lKeyData,lpbKeyState);//
- return ret;
- }
- long DllManager:: CreateWin(char* szClassName, char* szTitle,HWND hWndParent,DWORD himc)
- {
- if(NULL==hWinyDLL)
- return 0;
- hmainWin=myCreate(szClassName,szTitle,hWndParent,himc);//
- svhWndParent=hWndParent;
- return hmainWin;
- }
- long DllManager:: mgCreateWin(char* szClassName, char* szTitle,DWORD himc)
- {
- if(NULL==hWinyDLL)
- return 0;
- if(svhWndParent==0)
- return 0;
- if(hmainWin!=0)
- {
- CloseWin(&hmainWin);
- hmainWin=0;
- }
- hmainWin=myCreate(szClassName,szTitle,svhWndParent,himc);//
- return hmainWin;
- }
- long DllManager:: mgUpDateaWin(DWORD himc)
- {
- if(NULL==hWinyDLL)
- return 0;
- if(hmainWin!=0)
- {
- UpdateWinShow(&hmainWin,himc);
- }
- return 0;
- }
- long DllManager:: mgHideAllWin()
- {
- if(NULL==hWinyDLL)
- return 0;
- if(hmainWin!=0)
- {
- HideAllWin(&hmainWin);
- }
- return 0;
- }
- long DllManager:: mgHideWin()
- {
- if(NULL==hWinyDLL)
- return 0;
- if(hmainWin!=0)
- {
- HideWin(&hmainWin);
- }
- return 0;
- }
- long DllManager:: mgCloseWin()
- {
- if(NULL==hWinyDLL)
- return 0;
- if(hmainWin!=0)
- {
- CloseWin(&hmainWin);
- hmainWin=0;
- }
- return 0;
- }
- int DllManager::mgSetShowString(char*MindleStr,char*InputStr)
- {
- if(NULL==hWinyDLL)
- return 0;
- if(hmainWin!=0)
- {
- SetShowString(&hmainWin,MindleStr,InputStr);
- }
- return 0;
- }
- int DllManager::mgSetWinPosition(HWND hWnd ,POINT SetPos)
- {
- long x,y;
- if(NULL==hWinyDLL)
- return 0;
- if(hmainWin!=0)
- {
- x=SetPos.x;
- y=SetPos.y;
- SetWinPosition(&hmainWin,hWnd ,&x,&y);
- }
- return 0;
- }