DllManager.cpp
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:4k
源码类别:

输入法编程

开发平台:

Visual C++

  1. // mydebug.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include "windows.h"
  5. #include "stdio.h"
  6. #include "DllManager.h"
  7. DllManager:: DllManager()
  8. {
  9. int ret=0;
  10. HANDLE fd1;
  11. WIN32_FIND_DATAA tt ;
  12. hkeyDLL=NULL;
  13.   LoadErr=0;
  14.   // MessageBox (0,"Load TranChiDll.dll",0,0);
  15. fd1=FindFirstFile("c:\jsime\TranChiDll.dll",&tt);
  16.     if(fd1==INVALID_HANDLE_VALUE)
  17. {
  18.    //MessageBox(0,"文件TranChiDll.dll未找到!n 请立即保存,系统可能崩溃!?","c:\jsime\",0);
  19.    LoadErr=1;
  20. }
  21. else
  22. {
  23. hkeyDLL=LoadLibrary("c:\jsime\TranChiDll.dll");//加载动态链接库.dll文件; 
  24. m_creat=(m_pcreat)GetProcAddress(hkeyDLL,"creat"); 
  25. m_ChissToCodeC =(m_pChissToCodeC)GetProcAddress(hkeyDLL,"ChissToCodeC"); 
  26. m_DLLstart     =(m_pDLLstart)GetProcAddress(hkeyDLL,"DLLstart"); 
  27. m_SetIMEModle=(m_pSetIMEModle)GetProcAddress(hkeyDLL,"SetIMEModle"); 
  28. m_keyprogress=(m_pkeyprogress)GetProcAddress(hkeyDLL,"keyprogress"); 
  29. m_getnextpage=(m_pgetnextpage)GetProcAddress(hkeyDLL,"getnextpage"); 
  30. m_myclearbuf=(m_pClearBuf)GetProcAddress(hkeyDLL,"ClearBuf"); 
  31. m_creatNotest=(m_pcreatNotest)GetProcAddress(hkeyDLL,"creatNotest"); 
  32. m_insertNewWord=(m_pinsertNewWord)GetProcAddress(hkeyDLL,"insertNewWord"); 
  33. m_TestLib=(m_pTestLib)GetProcAddress(hkeyDLL,"TestLib"); 
  34. }
  35. }
  36. DllManager:: ~DllManager()
  37. {
  38. if(NULL!=hkeyDLL)
  39. {
  40. FreeLibrary(hkeyDLL);//卸载TranChiDll.dll文件;
  41. hkeyDLL=NULL;
  42. //MessageBox (0,"FreeLibrary",0,0);
  43. }
  44. }
  45. BOOL DllManager::creatNotest(char *CodeSource,char *userdefine,char *ExCodeSource,char *Code,long base, long goldeNum, long goldeLen)
  46. {
  47. BOOL ret=0;
  48. if(LoadErr==1)
  49. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  50. else
  51. ret=m_creatNotest(CodeSource,userdefine,ExCodeSource,Code,base, goldeNum, goldeLen);
  52. return ret;
  53. }
  54. long DllManager::TestLib(char *Code,long base, long goldeNum, long goldeLen,char *enchar,long showmsg,char **retstr)
  55. {
  56. long ret=0;
  57. if(LoadErr==1)
  58. MessageBox(0,"TestLib库加载失败函数","c:\jsime\",0);
  59. else
  60. ret=m_TestLib(Code,base, goldeNum, goldeLen,enchar, showmsg, retstr);
  61. return ret;
  62. }
  63. long DllManager::TestLibExt(char *Code,char *enchar,char *retstr)
  64. {
  65. long ret=0;
  66. char tt[1000]="",**pp,*p;
  67. p=tt;
  68. pp=&p;
  69. if(LoadErr==1)
  70. MessageBox(0,"TestLib库加载失败函数","c:\jsime\",0);
  71. else
  72. ret=m_TestLib(Code,64, 27, 4,enchar, 0, pp);
  73. strcpy(retstr,tt);
  74. return ret;
  75. }
  76. BOOL DllManager::creat(char *CodeSource,char *userdefine,char *ExCodeSource,char *Code,long base, long goldeNum, long goldeLen)
  77. {
  78. BOOL ret=0;
  79. if(LoadErr==1)
  80. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  81. else
  82. ret=m_creat(CodeSource,userdefine,ExCodeSource,Code, base, goldeNum, goldeLen);
  83. return ret;
  84. }
  85. /////////////////////////////////////////////////
  86. BOOL DllManager::insertNewWord(char *En,char *chi)
  87. {
  88. BOOL ret=0;
  89. if(LoadErr==1)
  90. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  91. else
  92. ret=  m_insertNewWord(En,chi);
  93. return ret;
  94. }
  95. BOOL DllManager::DLLstart   (int update)
  96. {
  97. BOOL ret=0;
  98. if(LoadErr==1)
  99. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  100. else
  101. ret=  m_DLLstart( update);
  102. return ret;
  103. }
  104. BOOL DllManager::SetIMEModle(int Mode)
  105. {
  106. BOOL ret=0;
  107. if(LoadErr==1)
  108. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  109. else
  110. ret=  m_SetIMEModle(Mode);
  111. return ret;
  112. }
  113. BOOL DllManager::keyprogress(int wparam,char*ss,char *SendENbuf, char* SendCH,char *Midtems,char* Control) //int wparam
  114. {
  115. BOOL ret=0;
  116. if(LoadErr==1)
  117. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  118. else
  119. ret=  m_keyprogress(wparam,ss,SendENbuf, SendCH,Midtems,Control) ;
  120. return ret;
  121. }
  122. BOOL DllManager::getnextpage( char *Midtems,int torword)
  123. {
  124. BOOL ret=0;
  125. if(LoadErr==1)
  126. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  127. else
  128. ret=  m_getnextpage(Midtems,torword);
  129. return ret;
  130. }
  131. BOOL DllManager::myclearbuf()
  132. {
  133. BOOL ret=0;
  134. if(LoadErr==1)
  135. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  136. else
  137. ret=  m_myclearbuf();
  138. return ret;
  139. }
  140. BOOL DllManager::ChissToCodeC(char *MainCodeLibName,char *chiss,char *codess)
  141. {
  142. BOOL ret=0;
  143. if(LoadErr==1)
  144. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  145. else
  146. ret= m_ChissToCodeC(MainCodeLibName,chiss,codess);
  147. return ret;
  148. }